| 23 | import { printDatasource } from '../utils/printDatasource' |
| 24 | |
| 25 | export class DbDrop implements Command { |
| 26 | public static new(): DbDrop { |
| 27 | return new DbDrop() |
| 28 | } |
| 29 | |
| 30 | private static help = format(` |
| 31 | ${process.platform === 'win32' ? '' : '💣 '}Drop the database |
| 32 | |
| 33 | ${bold(yellow('WARNING'))} ${bold( |
| 34 | `Prisma db drop is currently in Preview (${link('https://pris.ly/d/preview')}). |
| 35 | There may be bugs and it's not recommended to use it in production environments.`, |
| 36 | )} |
| 37 | ${dim('When using any of the subcommands below you need to explicitly opt-in via the --preview-feature flag.')} |
| 38 | |
| 39 | ${bold('Usage')} |
| 40 | |
| 41 | ${dim('$')} prisma db drop [options] --preview-feature |
| 42 | |
| 43 | The datasource URL configuration is read from the Prisma config file (e.g., ${italic('prisma.config.ts')}). |
| 44 | |
| 45 | ${bold('Options')} |
| 46 | |
| 47 | -h, --help Display this help message |
| 48 | --config Custom path to your Prisma config file |
| 49 | --schema Custom path to your Prisma schema |
| 50 | -f, --force Skip the confirmation prompt |
| 51 | |
| 52 | ${bold('Examples')} |
| 53 | |
| 54 | Drop the database |
| 55 | ${dim('$')} prisma db drop --preview-feature |
| 56 | |
| 57 | Specify a schema |
| 58 | ${dim('$')} prisma db drop --preview-feature --schema=./schema.prisma |
| 59 | |
| 60 | Use --force to skip the confirmation prompt |
| 61 | ${dim('$')} prisma db drop --preview-feature --force |
| 62 | `) |
| 63 | |
| 64 | public async parse(argv: string[], config: PrismaConfigInternal, baseDir: string): Promise<string | Error> { |
| 65 | const args = arg(argv, { |
| 66 | '--help': Boolean, |
| 67 | '-h': '--help', |
| 68 | '--preview-feature': Boolean, |
| 69 | '--force': Boolean, |
| 70 | '-f': '--force', |
| 71 | '--schema': String, |
| 72 | '--config': String, |
| 73 | '--telemetry-information': String, |
| 74 | }) |
| 75 | |
| 76 | if (isError(args)) { |
| 77 | return this.help(args.message) |
| 78 | } |
| 79 | |
| 80 | if (args['--help']) { |
| 81 | return this.help() |
| 82 | } |