| 25 | import { printFilesFromMigrationIds } from '../utils/printFiles' |
| 26 | |
| 27 | export class MigrateReset implements Command { |
| 28 | public static new(): MigrateReset { |
| 29 | return new MigrateReset() |
| 30 | } |
| 31 | |
| 32 | private static help = format(` |
| 33 | Reset your database and apply all migrations, all data will be lost |
| 34 | |
| 35 | ${bold('Usage')} |
| 36 | |
| 37 | ${dim('$')} prisma migrate reset [options] |
| 38 | |
| 39 | The datasource URL configuration is read from the Prisma config file (e.g., ${italic('prisma.config.ts')}). |
| 40 | |
| 41 | ${bold('Options')} |
| 42 | |
| 43 | -h, --help Display this help message |
| 44 | --config Custom path to your Prisma config file |
| 45 | --schema Custom path to your Prisma schema |
| 46 | -f, --force Skip the confirmation prompt |
| 47 | |
| 48 | ${bold('Examples')} |
| 49 | |
| 50 | Reset your database and apply all migrations, all data will be lost |
| 51 | ${dim('$')} prisma migrate reset |
| 52 | |
| 53 | Specify a schema |
| 54 | ${dim('$')} prisma migrate reset --schema=./schema.prisma |
| 55 | |
| 56 | Use --force to skip the confirmation prompt |
| 57 | ${dim('$')} prisma migrate reset --force |
| 58 | `) |
| 59 | |
| 60 | public async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> { |
| 61 | const args = arg(argv, { |
| 62 | '--help': Boolean, |
| 63 | '-h': '--help', |
| 64 | '--force': Boolean, |
| 65 | '-f': '--force', |
| 66 | '--schema': String, |
| 67 | '--config': String, |
| 68 | '--telemetry-information': String, |
| 69 | }) |
| 70 | |
| 71 | if (isError(args)) { |
| 72 | return this.help(args.message) |
| 73 | } |
| 74 | |
| 75 | if (args['--help']) { |
| 76 | return this.help() |
| 77 | } |
| 78 | |
| 79 | const schemaContext = await loadSchemaContext({ |
| 80 | schemaPath: createSchemaPathInput({ |
| 81 | schemaPathFromArgs: args['--schema'], |
| 82 | schemaPathFromConfig: config.schema, |
| 83 | baseDir, |
| 84 | }), |
nothing calls this directly
no test coverage detected
searching dependent graphs…