Replies: 2 comments
-
|
Actually the real issue you will encounter if the same PR deletes the column from the Drizzle schema + creates the migration to drop it is not about typings, but about the SQL that Drizzle will generate. Assuming that the schema migration is run first and then only the new code is deployed, between these two events, any |
Beta Was this translation helpful? Give feedback.
-
|
I'm running into the same issue with dropping columns in a safe way. When I remove a column from the schema, that will cause a migration to be generated when I run One hack that I've used is to do this in two steps:
This is harder than it should be and support for this in drizzle would be helpful (even a guide section in the docs on how to safely do migrations would help) |
Beta Was this translation helpful? Give feedback.
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-kitwouldn'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