-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run a migration by hand and update the migration table manually #9154
Comments
Can you please elaborate a bit what you mean by that exactly? What does "should be done concurrently" mean? |
Hi @janpio 😄
If you add a index to a tabel it will lock writes to it. Postgres supports writing a index
But a index Adding a column to a table with milions of rows took for me 5 mins adding it concurrently. Adding it without concurrent would have been quicker, but I did not want not to write to the tables at the same time. |
Ok. So you wanted to modify the generated migration vs. what |
@janpio Yes correct! |
Ok, so to recap:
Is that correct? |
@janpio Close, it is this steps
|
What command are you using to do this? If you commit a different migration (step 5) than what was run (step 3), I think it is probably expected to get a complaint because the checksum of the migration file is written in step 3, but then on next run compared to what was committed in step 5 - and those won't match. Does that make sense? (Of course does not help you to figure out a way how to run it the way you expect and want it to run) |
(For context, I work with Kevin, so I'm not just barging in :-)) I think your last message sums up the problem; the checksum in the table is based on the migration run in step 3, but the file on disk after step 5 generates a different checksum, so Prisma complains about those not matching ('The following migrations have been modified since they were applied'). The solution would seem to be to manually updating the checksum in |
Candidating this issue for discussion (at least), since we're working on migrate DX, and we may want to just remove these warnings (telling you if a migration has been edited is a job for |
@janpio is |
Everything that is not supported is on the roadmap - the question is when exactly. Right now |
Thanks for the update. That feature would really help with databases that have tables with millions of rows with a lot of traffic, as creating an index with locking is not feasible. |
@jho-gm did you find a simple way to generate the checksum (via bash, another command, etc.) of the updated migration? Thanks! |
Problem
Adding indexes should be done concurrently in postgres
Prisma generates indexes in the migration.
Indexes concurrently can't be added in a transaction
I run the migration manually by hand and comment out the add indexes while running
prisma migrate deploy
Afterwards Prisma deploy will say
Suggested solution
One solution could be:
Output the checksum so that I can update it manually
The text was updated successfully, but these errors were encountered: