Migrations are like version control for your database, allowing for replicable modifications to the database schema.

Through use of Prisma under the hood, Saruni allows you to write migrations declaratively by updating the schema.prisma file.

model User {
id Int @default(autoincrement()) @id
email String @unique
name String?

Generating migrations

To create a migration, use the db migrate save command.

yarn saruni db migrate save

You will be asked to supply a name for the migration and then you’re done! Each time you run the save command, a directory will be created in prisma/migrations with a dedicated detailing the changes made.

Running migrations

To run outstanding migrations, use the db migrate up command.

yarn saruni db migrate up

This command executes migrations against your database.