You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deleting a column from a table (to replace it with another column), my process is:
PR1: introduce a new column that is meant to replace it, fill it with some script.
at this point, the code still uses the old column, because the new column is empty until the script is run.
PR2: the code now uses the new column, which is made not nullable. Deprecate the old column, by deleting it from the schema, so we're sure the code cannot use the old column (you would get type errors).
The PR does not generate a migration to actually drop the column, because until the new version of the code is fully deployed, we can't be sure it's absolutely safe to drop it. (the CI first runs the schema migrations, then only deploys the new code gradually)
PR3: generate the actual migration to drop the old column.
It would be nice if PR2 didn't have to delete the old column from the schema to ensure that the application code doesn't use it anymore. Instead, it could use some kind of setting on the old column, that allows "deprecating" it. It would mean that the column is not visible anymore in the table's typescript type, but drizzle-kit wouldn't generate a migration to drop it. Something like: description: text('description').$deprecated()
The reason I'm suggesting this is that I find it awkward to accept that in some situations, there is a difference between the typescript schema and the DB schema. We try to run some tests as part of our CI to prevent people from merging things when such a discrepancy exists (the test generates a schema migration, and returns a failure if it was able to generate it). Some option to flag the columns where this discrepancy is expected would be useful.
I looked for this in the docs, but maybe I searched a bit too specifically for deletion of columns, and should have been looking for manipulating types in general?
Thanks for reading, and for maintaining a great tool!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When deleting a column from a table (to replace it with another column), my process is:
It would be nice if PR2 didn't have to delete the old column from the schema to ensure that the application code doesn't use it anymore. Instead, it could use some kind of setting on the old column, that allows "deprecating" it. It would mean that the column is not visible anymore in the table's typescript type, but
drizzle-kit
wouldn't generate a migration to drop it. Something like:description: text('description').$deprecated()
The reason I'm suggesting this is that I find it awkward to accept that in some situations, there is a difference between the typescript schema and the DB schema. We try to run some tests as part of our CI to prevent people from merging things when such a discrepancy exists (the test generates a schema migration, and returns a failure if it was able to generate it). Some option to flag the columns where this discrepancy is expected would be useful.
I looked for this in the docs, but maybe I searched a bit too specifically for deletion of columns, and should have been looking for manipulating types in general?
Thanks for reading, and for maintaining a great tool!
Beta Was this translation helpful? Give feedback.
All reactions