Database migrations
How to create and run database migrations in the Saas UI starterkit
Database migrations are a fundamental part of managing your database schema. They allow you to make changes to your database schema in a controlled and repeatable way. In the Saas UI starterkit, we use the Drizzle Kit CLI to manage database migrations.
Migration files
Migration files are generated by Drizzle Kit and live in the packages/db/drizzle directory.
Creating migrations
When you make changes to your database schema, you can generate a new migration file using the following command.
yarn db:generateThis will run the Drizzle Kit CLI and create a new migration file in the packages/db/drizzle directory.
Running migrations
To apply migrations run the following command:
yarn db:migratePrototyping database changes
If you want to iterate quickly during local development without having to create migrations you can directly push your schema changes to the database.
yarn db:pushOther commands
Drizzle Kit supports a range of other useful commands that can be run by calling the CLI directly.
See all commands in the Drizzle Kit docs.
# Drop migration
yarn workspace @acme/db drizzle-kit drop
# Check if migrations are consistent
yarn workspace @acme/db drizzle-kit check