5

I have some dictionary table in my DB schema. E.g. "EventType" whth fields "id" and "value".

This table have one row:

1    TypeOne

Can I create a prisma migration with sql?

INSERT INTO "EventType" (id, value) VALUES (2, 'TypeTwo')

1 Answer 1

11

All the prisma migration files are valid SQL so you can put any arbitrary SQL in your migration files and it will be added to your migration history.

This is what you have to do:

  1. Generate a new migration without applying it to the database with the --create-only flag.
npx prisma migrate dev --create-only
  1. Take a look at the generated migration.sql file and update it accordingly to add any new SQL statements.

  2. Apply the migrations npx prisma migrate dev

Important Note: Always make sure you apply the changes to migration.sql before applying it to your database. Modifying an already applied migration file will lead to a corrupt migration history.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.