Migrate the schema

Replay your Lovable Cloud schema onto your own Supabase project in DDL dependency order, gap-fill what replay misses, and resolve the common failures.

What runs in this step

Schema migration reconstructs your database structure on the destination before any row is copied. There is no pg_dump in the browser, so the schema is rebuilt from queries against information_schema and pg_catalog: extensions, types, tables, constraints, indexes, sequences, functions, triggers, and RLS policies. See schema replay for how the DDL is derived.

DDL dependency order

Objects are created in an order that satisfies their dependencies:

extensions → types → tables (no FK) → FK constraints
→ indexes → functions → triggers → RLS policies → publications

Foreign keys are added after every table exists, so a posts.author_id → users.id reference does not fail because users was created later. Enum and composite types are created before the tables that use them.

Gap-fill

Replay covers the objects introspection can see. A second pass diffs the destination against the source and fills gaps — a missing DEFAULT, an ungranted EXECUTE on a function, a sequence not yet owned by its column. Each statement is idempotent, so re-running the step after a failure does not double-create objects.

Common failures

  • type "..." does not exist — a table referenced an enum or composite type that was not created first. Re-run the step; the ordered pass creates types before tables.
  • relation "..." already exists — the object is already on the destination from a previous attempt. Safe to ignore, or drop the partial schema and start clean.
  • permission denied for schema ... — you are connected with a role that cannot create in that schema. Connect as postgres (the direct connection string, not a restricted role).

Each generated statement maps to a migration file you can inspect before it executes.

Verify

After the step completes, confirm the table count matches the source:

select count(*)
from information_schema.tables
where table_schema = 'public';

Compare against the same query on the source. RLS policies:

select schemaname, tablename, policyname
from pg_policies
where schemaname = 'public';

Next

With the structure in place, move on to migrating data — rows are inserted in FK-safe order and sequences are resynced afterward.

Edit this page on GitHubLast updated July 13, 2026