| 9 | } |
| 10 | |
| 11 | export async function setupPostgres(options: SetupParams): Promise<void> { |
| 12 | const { connectionString } = options |
| 13 | const { dirname } = options |
| 14 | const schema = fs.readFileSync(path.join(dirname, 'setup.sql'), 'utf-8') |
| 15 | |
| 16 | await createDatabase(connectionString).catch((e) => console.error(e)) |
| 17 | |
| 18 | const db = new Client({ |
| 19 | connectionString: connectionString, |
| 20 | }) |
| 21 | |
| 22 | await db.connect() |
| 23 | await db.query(schema) |
| 24 | await db.end() |
| 25 | } |
| 26 | |
| 27 | export async function tearDownPostgres(connectionString: string) { |
| 28 | const credentials = uriToCredentials(connectionString) |