Slackbot
08/07/2022, 6:06 AMRaphael Etim
08/08/2022, 9:43 AMCHECK constraint to it? If the latter is the case, then you can always edit a migration before applying it using the --create-only flag. Using this flag, creates a draft migration and you can proceed to modify the generated SQL file with the desired CHECK constraint before applying it using npx prisma migrate dev. For more information on customizing migrations, please see the documentation.Raphael Etim
08/08/2022, 11:01 AMprisma migrate dev, it replays the existing migration history in the shadow database in order to detect schema drift (edited or deleted migration file, or a manual changes to the database schema)
2. Applies pending migrations to the shadow database (for example, new migrations created by colleagues)
3. Generates a new migration from any changes you made to the Prisma schema before running migrate dev
4. Applies all unapplied migrations to the development database and updates the _prisma_migrations table
5. Triggers the generation of artifacts (for example, the Prisma Client)
The migrate dev command will prompt you to reset the database in the following scenarios:
• Migration history conflicts caused by modified or missing migrations
• The database schema has drifted away from the end-state of the migration history
See more details in the docs.Raphael Etim
08/08/2022, 1:53 PMnpx prisma migrate dev --create-only to create a migration file without applying it.
I edited the file to add a CHECK constraint.
Example:
ALTER TABLE "User"
ADD CONSTRAINT "image"
CHECK (
image IS NULL
);
After adding the check constraint, I executed npx prisma migrate dev to apply the check constraint. In this case the diff was not detected, if you add a CHECK constraint.
In case of index diff gets detected in some cases as described in this Github Issue.Raphael Etim
08/08/2022, 7:42 PM