MCPcopy
hub / github.com/prisma/prisma / parse

Method parse

packages/migrate/src/commands/MigrateReset.ts:60–169  ·  view source on GitHub ↗
(argv: string[], config: PrismaConfigInternal, baseDir: string)

Source from the content-addressed store, hash-verified

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 }),
85 })
86
87 const cmd = 'migrate reset'
88 const validatedConfig = validatePrismaConfigWithDatasource({ config, cmd })
89
90 const { migrationsDirPath } = inferDirectoryConfig(schemaContext, config)
91 const datasourceInfo = parseDatasourceInfo(schemaContext.primaryDatasource, validatedConfig)
92
93 printDatasource({ datasourceInfo })
94 checkUnsupportedDataProxy({ cmd, validatedConfig })
95
96 // TODO: check why the output and error handling here is different than in `MigrateDeploy`.
97 // Automatically create the database if it doesn't exist
98 const successMessage = await ensureDatabaseExists(
99 baseDir,
100 getSchemaDatasourceProvider(schemaContext),
101 validatedConfig,
102 )
103 if (successMessage) {
104 process.stdout.write('\n' + successMessage + '\n')
105 }
106
107 process.stdout.write('\n')
108 if (!args['--force']) {
109 if (!canPrompt()) {
110 throw new MigrateResetEnvNonInteractiveError()
111 }
112
113 const confirmation = await prompt({
114 type: 'confirm',
115 name: 'value',
116 message: `Are you sure you want to reset your database? ${red('All data will be lost')}.`,
117 })

Callers

nothing calls this directly

Calls 15

helpMethod · 0.95
argFunction · 0.90
isErrorFunction · 0.90
loadSchemaContextFunction · 0.90
createSchemaPathInputFunction · 0.90
inferDirectoryConfigFunction · 0.90
parseDatasourceInfoFunction · 0.90
printDatasourceFunction · 0.90
ensureDatabaseExistsFunction · 0.90

Tested by

no test coverage detected