Sync UI-created tables/functions into local migrations #48636
Replies: 2 comments 3 replies
|
This would remove a real source of drift. I would make the first version an explicitly reviewable, non-authoritative export, rather than treating an internal record of UI-generated SQL as the source of truth. For example, an export could generate one migration made of object-level DDL, ordered deterministically by dependencies, together with a base-state fingerprint (such as the local migration head plus a schema checksum). Before writing the migration, the command could refuse or require an explicit choice when that base state no longer matches. That gives useful behaviour in the cases that are otherwise risky:
In the latter two cases, surfacing a conflict is preferable to silently producing a migration that duplicates or overwrites DDL. How do you see this composing with |
|
@ahmedsam199 Yes — that is no longer mainly an export problem; it is a recovery and re-baselining problem. The important good news is that you do not need to reconstruct the original sequence of Studio clicks to recover. You need the team to deliberately choose the current production catalog as the canonical snapshot at one point in time, then make Git reproducible from it. A safe recovery runbook would be:
That separates two things that are easy to conflate: adopting the current production state into history and running a change against production. The first is what repairs your project; the second would be dangerous in this case. For the product, I think this deserves a first-class guided command such as “Adopt remote schema into migrations”, not merely another diff button. Its preflight should show: local migration head, remote migration history, object-level diff, and a schema fingerprint. Its final screen should make the two actions explicit: “write reviewed migration to Git” and, only for the canonical remote, “mark this migration as already represented”. If the fingerprint changes during the flow, it must stop rather than guess. The success criterion is wonderfully concrete: a new developer can clone the repository, reset locally, and run the app without any hidden Studio-created table. Once that invariant holds, Studio can still be convenient, but every change needs a visible path back into version control. Would a guided recovery path like this have let you rescue that application without manually rediscovering every missing table? |
Uh oh!
There was an error while loading. Please reload this page.
When a table, function, or other schema object is created through the Studio UI, there's currently no easy way to bring that change into local migrations — you either rewrite the SQL manually or pull a full DB dump.
Idea: Track the SQL definition of anything created via the UI in an internal table, then let developers run a command locally to pull all pending changes and generate proper migration files in one go — instead of one huge SQL dump.
All reactions