(connectionString: string, cwd = process.cwd(), schemaEnginePath?: string)
| 141 | } |
| 142 | |
| 143 | export 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 | |
| 168 | export async function execaCommand({ |
| 169 | connectionString, |
no test coverage detected