MCPcopy
hub / github.com/prisma/prisma / runCommand

Method runCommand

packages/migrate/src/SchemaEngineWasm.ts:82–124  ·  view source on GitHub ↗
(
    command: M,
    input: SchemaEngineInput<M>,
  )

Source from the content-addressed store, hash-verified

80 }
81
82 private async runCommand<M extends keyof SchemaEngineMethods>(
83 command: M,
84 input: SchemaEngineInput<M>,
85 ): Promise<Awaited<SchemaEngineOutput<M>>> {
86 if (process.env.FORCE_PANIC_SCHEMA_ENGINE && command !== 'debugPanic') return this.debugPanic()
87
88 this.isRunning = true
89
90 debugStdout('[%s] input: %o', command, input)
91
92 try {
93 // Don't modify this by extracting the method call into a variable,
94 // as it breaks the binding to the WebAssembly instance, and triggers the
95 // `TypeError: Cannot read properties of undefined (reading '__wbg_ptr')`
96 // error.
97 const result = await (this.engine[command] as (_: SchemaEngineInput<M>) => SchemaEngineOutput<M>)(input)
98 debugStdout('[%s] result: %o', command, result)
99 return result
100 } catch (error) {
101 const e = error as Error
102 debugStdout('[%s] error: %o', command, e)
103
104 if (isWasmPanic(e)) {
105 debugStdout('[schema-engine] it is a Wasm panic')
106 const { message, stack } = getWasmError(e)
107 // Handle error and displays the interactive dialog to send panic error
108 throw new RustPanic(serializePanic(message), stack, command, ErrorArea.LIFT_CLI)
109 } else if ('code' in error) {
110 throw new EngineError(red(`${error.code}\n\n${relativizePathInPSLError(error.message)}\n`), error.code)
111 } else {
112 assertAlways(
113 e.name === 'SchemaConnectorError',
114 'Malformed error received from the engine, expected SchemaConnectorError',
115 )
116
117 debugStderr('e.message', e.message)
118 debugStderr('e.cause', e.cause)
119 debugStderr('e.stack', e.stack)
120
121 throw e
122 }
123 }
124 }
125
126 /**
127 * Apply the migrations from the migrations directory to the database.

Callers 15

applyMigrationsMethod · 0.95
createMigrationMethod · 0.95
dbExecuteMethod · 0.95
debugPanicMethod · 0.95
devDiagnosticMethod · 0.95
evaluateDataLossMethod · 0.95
getDatabaseVersionMethod · 0.95
introspectMethod · 0.95
migrateDiffMethod · 0.95
markMigrationAppliedMethod · 0.95

Calls 6

debugPanicMethod · 0.95
isWasmPanicFunction · 0.90
getWasmErrorFunction · 0.90
relativizePathInPSLErrorFunction · 0.90
assertAlwaysFunction · 0.90
serializePanicFunction · 0.70

Tested by

no test coverage detected