Is there a way to do a "down" migration with Drizzle?
I'm looking at the docs of Drizzle migrations and I can't seem to find how to write migrations that can be rolled back.
14 Replies
remove the column from one of your tables in the drizzle schema and regenerate and migrate.
i'm not sure I understand
Is there an official way of downgrading?
When you remove an attribute from the table schema, drizzle kit calculates what changed and generates the correct migration to drop the column.
ah, I see, thanks
so there is no built-in support
I interpret this as built in support. But there is no way to define a down migration. It's handled for you. If you'd like to delete the migration file you can go through the steps above and then run the drop command here https://orm.drizzle.team/kit-docs/commands#drop-migration
Drizzle ORM - List of commands
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
this is what I mean by up and down: https://kysely.dev/docs/migrations
Migrations | Kysely
Migration files should look like this:
Liquibase Rollback Workflow
This page explains the rollback workflows in Liquibase.
The problem is that there can be changes in a migration that can't be undone (custom queries and stuff like that) automatically
@addamsson it is an open feature request: https://github.com/drizzle-team/drizzle-orm/discussions/1339
GitHub
Migrations Rollback · drizzle-team drizzle-orm · Discussion #1339
Hi #drizzle-team & community folks 👋 I'd like to suggest something that I believe more people might be looking for. Is there any plan for rollback migrations? My day-to-day workflow Because...
This is a huge omission
there are plenty as I've discovered in the last few days when I tried to migrate my prisma project 😅
The main ones for me are
1. No down migration
2. No nested operations like nested insert
also no nested queries so i cant even do a n:m query with the query api
kinda makes the query api useless
Hello, I just made this small lib today that adds
up
and down
in drizzle using some drizzle-kit internals, that they are using to make migrations work inside payloadcms. This is very early and work still in progress, but give it a try and maybe try to contribute too.
https://www.npmjs.com/package/@drepkovsky/drizzle-migrations?activeTab=readmenpm
@drepkovsky/drizzle-migrations
Tiny tool for managing migrations in Drizzle. Latest version: 0.1.3, last published: a minute ago. Start using @drepkovsky/drizzle-migrations in your project by running
npm i @drepkovsky/drizzle-migrations
. There are no other projects in the npm registry using @drepkovsky/drizzle-migrations.