Migrations[src]
Non-destructive migrations
Both immigrant commit-unchecked and immigrant-migrate commit accept --non-destructive, which controls what happens with data, when a table or a column is removed from the schema. Indexes, constraints and other objects which don't hold data are dropped as usual.
| Mode | Behavior |
|---|---|
|
Generating the migration fails, if it would drop a table or a column. |
|
Dropped tables and columns are renamed to |
any other value |
Same as |
Kept objects are detached from the rest of the schema, so they don't prevent future migrations:
-
foreign keys, constraints, indexes, policies and grants of kept tables are dropped;
-
kept columns lose
NOT NULLand defaults; -
columns of enum and struct types are converted to
TEXT, columns of domain types to the underlying type.
The id used for kept objects is stored in the migration, so immigrant regenerate-sql produces the same SQL:
## Non-destructive
keep 12
Obsolete objects are not tracked by immigrant, drop them manually once the data is no longer needed.