-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inability to Revert Migrations in Drizzle #183
Comments
@AndriiSherman URGENT This is big deal, running |
@fireayehu what is the case for you to revert the migration? Would it be production deploy or something else? |
@fireayehu I created post on reddit how to work with migrations and what to not do because of potential mess up. |
Got your concerns, but at least there needs to be a way to revert last run migrations. Awesome post btw |
@AndriiSherman In both cases, but for now on development. Let's say I created a couple of table schemas, then generated and run the migration. After that if I changed my mind and wanted to remove on of those tables from my last migration, in drizzle way I can drop my last migration, then remove one of the schema and generate a new migration and run it. But in the database both of the tables with their constraints will be available. So I manually have to go to the db and make the changes The way am seeing it is NB: One more thing I noticed is dropping a migration does not remove the migration row from the migration table in the database. |
linked to #36 |
In the drizzle-orm repository, the issue was closed by the drizzle team with a wont fix. (Note: link) Anyway, Drizzle has a DX that I'm happy with, and I'm using it well. Thanks to the Drizzle team. 👍🏻 |
Problem Description
In TypeORM, reverting a database migration is straightforward due to the
up()
anddown()
methods generated with each migration file. Drizzle, however, lacks this essential feature, making it difficult to rollback database schema changes.Steps to Reproduce
TODO
with fields{id, title}
.description
to theTODO
table so that the schema becomes{id, title, description}
.{id, title}
.drizzle-kit drop
to choose which migration file to delete. Assume you remove the last generated file that adds the 'description' field.{id, title}
.Issues Encountered
drizzle-kit generate:{dialect}
results in an empty file. This is because Drizzle checks the last migration file and the current schema, both of which are{id, title}
, thus seeing no changes to migrate.Suggested Improvement
Implement functionality similar to TypeORM’s
up()
anddown()
methods to facilitate easy migration rollbacks.Note
I would have contributed this feature myself, but unfortunately, Drizzle-kit doesn't seem to be open source.
The text was updated successfully, but these errors were encountered: