| 4 | import { bold, dim, red } from class="st">'kleur/colors' |
| 5 | |
| 6 | export class MigrateCommand implements Command { |
| 7 | public static new(cmds: Commands): MigrateCommand { |
| 8 | return new MigrateCommand(cmds) |
| 9 | } |
| 10 | |
| 11 | private static help = format(` |
| 12 | Update the database schema with migrations |
| 13 | |
| 14 | ${bold(class="st">'Usage')} |
| 15 | |
| 16 | ${dim(class="st">'$')} prisma migrate [command] [options] |
| 17 | |
| 18 | ${bold(class="st">'Commands for development')} |
| 19 | |
| 20 | dev Create a migration from changes in Prisma schema, apply it to the database |
| 21 | trigger generators (e.g. Prisma Client) |
| 22 | reset Reset your database and apply all migrations, all data will be lost |
| 23 | |
| 24 | ${bold(class="st">'Commands for production/staging')} |
| 25 | |
| 26 | deploy Apply pending migrations to the database |
| 27 | status Check the status of your database migrations |
| 28 | resolve Resolve issues with database migrations, i.e. baseline, failed migration, hotfix |
| 29 | |
| 30 | ${bold(class="st">'Command for any stage')} |
| 31 | |
| 32 | diff Compare the database schema from two arbitrary sources |
| 33 | |
| 34 | ${bold(class="st">'Options')} |
| 35 | |
| 36 | -h, --help Display this help message |
| 37 | --config Custom path to your Prisma config file |
| 38 | --schema Custom path to your Prisma schema |
| 39 | |
| 40 | ${bold(class="st">'Examples')} |
| 41 | |
| 42 | Create a migration from changes in Prisma schema, apply it to the database, trigger generators (e.g. Prisma Client) |
| 43 | ${dim(class="st">'$')} prisma migrate dev |
| 44 | |
| 45 | Reset your database and apply all migrations |
| 46 | ${dim(class="st">'$')} prisma migrate reset |
| 47 | |
| 48 | Apply pending migrations to the database in production/staging |
| 49 | ${dim(class="st">'$')} prisma migrate deploy |
| 50 | |
| 51 | Check the status of migrations in the production/staging database |
| 52 | ${dim(class="st">'$')} prisma migrate status |
| 53 | |
| 54 | Specify a schema |
| 55 | ${dim(class="st">'$')} prisma migrate status --schema=./schema.prisma |
| 56 | |
| 57 | Compare the database schema from two databases and render the diff as a SQL script |
| 58 | ${dim(class="st">'$')} prisma migrate diff \\ |
| 59 | --from-url class="st">"$DATABASE_URL" \\ |
| 60 | --to-url class="st">"postgresql:class="cm">//login:password@localhost:5432/db" \\ |
| 61 | --script |
| 62 | `) |
| 63 | |