Glossary

schema replay

Schema replay recreates a source Postgres schema on a destination by re-running migration files and reconstructing ad-hoc objects through introspection.

schema replay is the process of recreating a source Postgres schema on a destination database by re-running its migration files and reconstructing any objects that the migration files do not cover.

In a Lovable Cloud project, not every schema object lives in a migration file. Tables, columns, functions, and policies created ad-hoc in the SQL editor exist only in the live database, not in version control. Schema replay handles both sources: it applies the tracked migration files, then does a "gap-fill" pass that introspects information_schema and pg_catalog on the source to find and recreate the untracked objects. This matters because pg_dump is not available in a browser or Edge Function, so the schema has to be reconstructed from queries rather than a binary dump.

Objects are replayed in dependency order so each statement's requirements already exist:

extensions → types → tables → foreign keys → indexes
→ functions → triggers → policies

Tables are created before foreign keys so that referenced tables exist when a constraint is added, and functions are created before the triggers that call them. After DDL replay, sequences still need a sequence resync once data is loaded, since replaying the schema alone does not advance sequence values. See Migrate schema for the full step order and how gap-filled objects are logged.

Related terms