Temm
08/06/2021, 11:18 PMprisma db push
2 being prisma migrate dev
but this doesnt seem to be the case: when running 2 locally, it warns me that database drift has been detected, and it will have to reset my database
Can someone help with this?
What is the correct way of doing this?Daniel Olavio Ferreira
08/07/2021, 2:21 PMprisma db push
will only apply the migration history to your database, and the prisma migrate dev
will do it , and create a new migration. So I believe that what you need to do is run prisma migrate dev
locally, to generate the new migration. When pulling from the server you can use the prisma db push
to apply the current schema to the database, without creating a new migration, that has to be sync.Daniel Olavio Ferreira
08/07/2021, 2:23 PMTemm
08/12/2021, 6:11 PMprisma db push
i've been using prisma db push to sync the database with the schema without creating a migration (because that is what it does - at least thats the effect i observed)
This will of course sync the database with the schema, but desync it with the migration history.
I am definetly unable to manually create the migrations - i chose prisma because i want to avoid writing SQL as much as possible.
Isnt there a command that creates a migration from the last state of the migration history to the current state of the database/schema?Daniel Olavio Ferreira
08/12/2021, 6:29 PMTemm
08/12/2021, 7:56 PMprisma migrate
didnt do any changes aside from reordering things and adding @@index
to models.
This was what i expected - my test database was already in sync with my schema, just my migration history was catching behind because i pushed the schema to the database via prisma db push
instead of prisma migrate dev
.
My question was, how i can generate the migration files to bridge the gap between the current migration state and the current schema state - i dont want to do any operations on the database, as it is already in sync with my prisma schema.
Isnt there a command to just do exactly that? I used prisma db push
to avoid spamming migrations when making tiny testing changes in my dev envoirement - i dont want to create a hundred tiny unnessecary migrations for that.Daniel Olavio Ferreira
08/12/2021, 8:00 PMprisma migrate dev --create-only
I believe this would work then. Just double check that this is the correct syntax for the command. This should only generate the migrations without trying to sync with your databaseTemm
08/12/2021, 8:06 PMDaniel Olavio Ferreira
08/12/2021, 8:16 PMTemm
08/12/2021, 8:26 PM@@index
)
So i dont think that this is what i want eitherDaniel Olavio Ferreira
08/12/2021, 8:44 PMTemm
08/12/2021, 9:20 PMRyan
08/13/2021, 7:30 AMprisma db push
to prototype and make any changes you want.
2. Run prisma migrate dev
and apply migrations (this will reset your data)Temm
08/13/2021, 12:11 PMRyan
08/13/2021, 12:13 PMRyan
08/13/2021, 12:13 PMRyan
08/13/2021, 12:20 PMmigrate dev
so that you database contains the necessary data.
I would suggest upvoting this request as it’s quite similar to your use case.Temm
08/15/2021, 12:55 AMprisma db push
on the live server, instead of having created a migration indev and then applying that on the server.
This means that im now unable to apply the migration on my live server, as doing so would require a database reset, even though the prisma schema and the database schema are already in sync, simply because i had missused the commands and not created a migration.
What is the way out of this?
Forcing the developer to reset the database to create a migration even though the prisma schema and the database schema are already in sync seems a bit arbitrary - could this not be removed, is it really a hard requirement?
I know that i made quite a mistake by not using migrations, but this is my current situation.Ryan
08/16/2021, 5:24 AMprisma migrate resolve
for the migrations to the production environment.