| 1 | import path from 'node:path'; |
| 2 | import { |
| 3 | BucketAlreadyOwnedByYou, |
| 4 | CreateBucketCommand, |
| 5 | S3Client, |
| 6 | } from '@aws-sdk/client-s3'; |
| 7 | import { createDatabase } |
| 8 | import { migrate } |
| 9 | |
| 10 | import { |
| 11 | DATABASE_URL, |
| 12 | hasBackends, |
| 13 | S3_ENDPOINT, |
| 14 | s3Credentials, |
| 15 | } from './harness.js'; |
| 16 | |
| 17 | const MIGRATIONS = path |
| 18 | import.meta.dirname, |
| 19 | '../../../packages/db/drizzle', |
| 20 | ); |
| 21 | |
| 22 | // Once for every suite: suites run in parallel, and two migrators racing on a fresh database collide creating the journal table. |
| 23 | export default async function |
| 24 | if (!hasBackends) |
| 25 | |
| 26 | const { db, |
| 27 | await migrate(db |
| 28 | await pool.end |
| 29 | |
| 30 | await new S3Client |
| 31 | endpoint: S3_ENDPOINT, |
| 32 | region: 'auto', |
| 33 | forcePathStyle: true, |
| 34 | credentials: { |
| 35 | accessKeyId: s3Credentials.S3_ACCESS_KEY_ID |
| 36 | secretAccessKey: s3Credentials.S3_SECRET_ACCESS_KEY |
| 37 | }, |
| 38 | }) |
| 39 | .send(new CreateBucketCommand |
| 40 | .catch((error: |
| 41 | if (!(error |
| 42 | }); |
| 43 | } |