Drizzle migrations workflow with CICD and multi-dev teams

Hi! I'm looking into ORMs to use for my team in a new Node/TS project, and Drizzle has caught my attention. tldr: Is it possible to use Drizzle in a CICD pipeline to apply migrations? One thing that I don't have clarity on is how Drizzle would work in an environment where multiple devs are working on migrations concurrently. With other ORMs I have used, I've setup our codebase such that devs are able to create and apply migrations in their local environment, commit the migrations, and merge into master. Then, a CICD pipeline applies the migration to the prod database. This ensures that there are no conflicting migrations (the migration will fail to build/run), and ensures safeguards against modifying the prod database without proper reviews. A core aspect of this is that migration metadata is stored in the database, allowing the same set of migrations to be applied to different databases (local/staging/prod). However, with Drizzle, it looks like migration metadata is stored in the codebase, which makes me think it would be difficult to apply migrations in a CI environment (doing so would mean that CI pipelines need to be able to commit code to our repo, which sounds iffy). Am I on the right track here? Has someone successfully setup a CI pipeline that applies Drizzle migrations?
3 Replies
Andrii Sherman
Drizzle stores metadata both in database and codebase so even working with a multiple devs you can be sure, that migrations are in sync Also we have this command called "drizzle-kit check" that can help you find any collisions appeared by multiple devs trying to generate a migration on different branches and then merging it to dev/staging/etc. without syncing https://orm.drizzle.team/kit-docs/commands#check
spoder7651
spoder7651OP2y ago
Thank you. Quick question, if metadata is stored both in the database and codebase, then what's the risk of not committing the files found under /drizzle/meta/*?
Andrii Sherman
Those files are needed to find collisions as well as getting a list of sql files in right order before applying to database
Want results from more Discord servers?
Add your server