Loading Depth Study
Preparing your workspace
Database migrations provide a versioned and repeatable history of changes to the PostgreSQL schema.
Supabase projects can manage database structure through SQL migrations. Migrations can create tables, alter columns, add constraints, create indexes, enable RLS, and define policies or functions. Versioned migrations make development, staging, and production environments easier to synchronize. Important schema changes should be reviewed and tested because database changes can affect existing application code.
Adding an organization_members table, an audit log table, and related RLS policies can be represented as migrations.
create table organization_members ( id uuid primary key default gen_random_uuid(), organization_id uuid not null, user_id uuid not null, role text not null, created_at timestamptz not null default now() ); create index idx_org_members_user on organization_members(user_id);
A migration can create the organization_members table and an index for user lookups.