I ran introspect:pg to initialize my schema, then created a new migration. How should I deploy this?

The remote database, right now, doesn't have the drizzle.__drizzle_migrations table. It'd be nice to have a way to know that the old migrations - the ones that were generated by introspect:pg and just reflect the existing state of the database - won't run. Is this the right way to look at it? Thanks!
9 Replies
Andrii Sherman
Andrii Sherman15mo ago
yeah you a right. Introspect should cover all migration code in comments, so this file won't apply to database you can check generated sql after introspection and all it will do just create an entity in drizzle.__drizzle_migrations table
tmcw
tmcw15mo ago
Oh! Okay. So for I should comment out the migrations that are "pre-drizzle." That works… how should this work with fresh databases that don't have any of this structure?
Andrii Sherman
Andrii Sherman15mo ago
We are still on our way to come up with proper solution. As for now I guess comment/uncomment will work. Not ideal I think we can mark introspected migrations in _journal and then give some sort of options for migration running in drizzle-orm part. Some boolean, that will say if we need run introspected migration or not Didn't think about all cases so far, as long there were no need for our projects or anyone else. But this is a good case to discuss and implement If you have any thoughts on what I've explained or have any ideas - will be happy to hear them and implement! As I remember you are the first to mention this case, so maybe it's time to make it better
tmcw
tmcw15mo ago
I think commenting and uncommenting would work. Trying to remember how Prisma dealt with this scenario 😆 .
Andrii Sherman
Andrii Sherman15mo ago
We will prepare a big set of different cases for migrations/introspecting to place in docs Will cover this one also
andreterron
andreterron15mo ago
Hi, I work with @tmcw 👋. The way I'd expect is to have a command that would mark a migration as executed without executing it optionally having a flag during introspection to already mark the generated migration as executed on the DB it's connecting to
Andrii Sherman
Andrii Sherman15mo ago
Hi! that make sense actually. I guess we can add it together with running migrations directly from drizzle-kit because for now it's possible manually or from drizzle-orm Thanks a lot, I'll write down your suggestions
tmcw
tmcw15mo ago
Thanks Andrew!
andreterron
andreterron15mo ago
Thank you!