MCPcopy
hub / github.com/prisma/prisma / dropDatabase

Function dropDatabase

packages/internals/src/schemaEngineCommands.ts:143–166  ·  view source on GitHub ↗
(connectionString: string, cwd = process.cwd(), schemaEnginePath?: string)

Source from the content-addressed store, hash-verified

141}
142
143export async function dropDatabase(connectionString: string, cwd = process.cwd(), schemaEnginePath?: string) {
144 try {
145 const result = await execaCommand({
146 connectionString,
147 cwd,
148 schemaEnginePath,
149 engineCommandName: 'drop-database',
150 })
151 if (result && result.exitCode === 0 && result.stderr.includes('The database was successfully dropped')) {
152 return true
153 } else {
154 // We should not arrive here normally
155 throw Error(`An error occurred during the drop: ${JSON.stringify(result, undefined, 2)}`)
156 }
157 } catch (e: any) {
158 if (e.stderr) {
159 const logs = parseJsonFromStderr(e.stderr)
160
161 throw new Error(`Schema engine error:\n${logs.map((log) => log.fields.message).join('\n')}`)
162 } else {
163 throw new Error(`Schema engine exited. ${e}`)
164 }
165 }
166}
167
168export async function execaCommand({
169 connectionString,

Callers 2

parseMethod · 0.90

Calls 3

execaCommandFunction · 0.85
parseJsonFromStderrFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected