This message was deleted.
# orm-help
s
This message was deleted.
r
Hi @Peter 👋 Can please clarify what you mean by added externally? Do you mean editing the migration file and adding the
CHECK
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.
1. When you run
prisma 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.
Hi @Peter, I have verified by adding a CHECK constraint, I can execute
npx prisma migrate dev --create-only
to create a migration file without applying it. I edited the file to add a CHECK constraint. Example:
Copy code
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.
You're welcome.