Fix/move table schema migrations#758
Conversation
|
I think we may need to ask if you are renaming the schema or not interactively, similar to how we do with other renames. The reason for this is that I think there could be some weirdness here if you have the same table but in different schemas. We may want some tests around those scenarios as well. |
|
That's a good point. I agree this should probably mirror the table rename behavior. The current logic assumes one same-table/different-schema candidate means a schema move, but that could be ambiguous if an unrelated table with the same name is added in another schema. I can add an interactive confirmation and tests around that case. |
|
Added the suggested prompt handling for inferred schema moves. If the user declines the schema move, the generator treats the target-schema table as new and falls back to the existing orphan-table drop prompt for the old table, allowing the same table name to intentionally exist in different schemas. |
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
Resolves issue #731
Fixes schema-only resource changes being generated as
drop table+create table.The generator matches snapshots by
{table, schema}, so changing onlyschema "..."made the old table look removed and the new schema table look newly added. This PR detects same-table/different-schema changes as schema moves and emitsALTER TABLE ... SET SCHEMA ...instead, preserving existing data.Changes
MoveTableSchemaoperation.Added test coverage for: