#Can I get Prisma to give me the full migrate+deploy SQL as a string?

4 messages · Page 1 of 1 (latest)

graceful shoal
#

I'm exploring blue/green deployment and zero-down-time releases, and would love to know if I can get prisma migrate deploy to give me all of the SQL it's going to run as a string?

For example, lets say we add a column to a table

  • we'd have a file in prisma/migrations/[datetime]_add_column/migration.sql
  • prisma migrate deploy would theoretically run the contents of that file in a DB
  • and then it would run insert into _prisma_migrations (id,checksum,finished_at,migration_name,logs,rolled_back_at,started_at,applied_steps_count) values (...)

I'd live to be able to use gh-ost to do the DB migrations in a non-blocking way, so I can keep my site up while deploying and only have a little blip as one docker image stops and the other starts up. But to do that I'd need to get all of the migration SQL and the _prisma_migrations insert/update SQL as a string, I believe.

Is there a way I can coax from Prisma all of the SQL it's going run run as migrate deploy as a string (assuming success)? Ooh, or maybe I can get 2 strings: what to run if success, and what to run in the case of failure!

GitHub

GitHub's Online Schema-migration Tool for MySQL. Contribute to github/gh-ost development by creating an account on GitHub.

inland pawnBOT
#

You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.

graceful shoal
#

Oh, interesting, I may not need the migration as one long string with gh_ost. I can just run the migration on a replica then use gh_ost to copy that to master. I'm looking into that now...

graceful shoal
#

Turns out that gh-ost is really just for running a single schema change on one table, so it's really not a good fit for Prisma migrations which, at least for us, are almost never discrete. Usually they're adding and populating a column, or similar. So I'll look into other ways to do zero-down-time schema changes.