Marking Migrations

Hello all, I want to ask if it is possible to mark migrations as applied like in django ? https://docs.djangoproject.com/en/5.1/ref/django-admin/#cmdoption-migrate-fake Reason being, I'm building with (https://encore.dev) where the system needs to apply the migrations on startup, I managed to generate migrations with drizzle but each time I generate it does not track the state of the database schema, which makes sense. But if there was a way to mark a migration as applied, drizzle can still keep track of changes in the schema. Please let me know if this makes sense or if I should approach this differently. My workflow: - Create drizzle schema - Generate migrations with drizzle-kit - Start up encore that applies the migration based on the index of the migration file name - Change column name in schema ❌ Generate migration again but just drizzle-kit does not recognise previous migration as a new migration just contains CREATE TABLE statements with changed column name
Encore
Encore — Development Platform for type-safe distributed systems
Encore is a Development Platform that lets you build robust distributed systems, using a high-performance backend framework with declarative infrastructure.
Django Project
django-admin and manage.py | Django documentation
The web framework for perfectionists with deadlines.
6 Replies
Angelelz
Angelelz3mo ago
Drizzle kit keeps track of the applied migration by marking it in a __drizzle_migrations table that it creates in the database
powerhousejnr248
powerhousejnr248OP3mo ago
Yes it saves index, hash and date created, can I apply this migration marking without applying the migration to my database schema ?
Angelelz
Angelelz3mo ago
I'm sorry, I don't understand the question. In the last step of your workflow, you state that drizzle-kit does not recognise previous migration. This has to be an error in configuration or the like, because drizzle-kit will generate a migration based on the changes it sees in your schema and the latest migration
powerhousejnr248
powerhousejnr248OP3mo ago
Hey @Angelelz , thanks for the response. To clarify further, the reason Drizzle isn't recognizing the changes is that Encore is applying the migrations using its own migration strategy. I’m just using Drizzle to generate the migrations with drizzle-kit. What I want is to mark a migration as applied (similar to Django's --fake option) so Drizzle recognizes the latest migration without actually applying it to the database schema. This way, Drizzle won’t generate redundant CREATE TABLE statements, but will still track the state of the schema and the applied migrations correctly. Does that help clarify my situation? I'd appreciate any suggestions on how to approach this
Angelelz
Angelelz3mo ago
I understand. But drizzle-kit already does that. Whenever you generate a migration, it also creates metadata to keep track of new changes you make to your typescript schema, regardless of what has been applied to the database. After a migration is generated with the generate command, if you try to generate another one, nothing will be generated because it will have detected that the latest changes have already been accounted for and generated That’s why I think you may have a misconfigiration or you might be deleting the migrations folder that drizzle generates
powerhousejnr248
powerhousejnr248OP3mo ago
Oh ok thanks @Angelelz , this was because I used no prefix and manipulated the file name, but I'll find a work around
Want results from more Discord servers?
Add your server