Skip to content

Commit 8e398f7

Browse files
committed
Close the migration suite's database handle after the run
1 parent e18a59d commit 8e398f7

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/migrations.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { beforeAll, describe, expect, test } from "bun:test";
1+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
22
import { getTableName, is, sql } from "drizzle-orm";
33
import { PgTable } from "drizzle-orm/pg-core";
44
import { createArtifactDb } from "./db.js";
@@ -23,7 +23,7 @@ const DECLARED_TABLES = (Object.values(schema) as unknown[])
2323
.map(getTableName)
2424
.sort();
2525

26-
const { db } = createArtifactDb(DATABASE_URL);
26+
const { db, close } = createArtifactDb(DATABASE_URL);
2727

2828
async function packageTables(): Promise<string[]> {
2929
const rows = await db.execute<{ table_name: string }>(sql`
@@ -45,6 +45,8 @@ beforeAll(async () => {
4545
await ensureControlPlane(db);
4646
});
4747

48+
afterAll(close);
49+
4850
describe("runArtifactMigrations", () => {
4951
test("creates exactly the tables schema.ts declares, and re-running is a no-op", async () => {
5052
await db.execute(sql`DROP SCHEMA IF EXISTS ${sql.identifier(SCHEMA)} CASCADE`);

0 commit comments

Comments
 (0)