8da610a895
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
25 lines
852 B
JavaScript
25 lines
852 B
JavaScript
"use strict"
|
|
|
|
const test = require("node:test")
|
|
const assert = require("node:assert/strict")
|
|
const { withTestDatabase } = require("./helpers/db-test.cjs")
|
|
const { runMigrations } = require("../lib/db.cjs")
|
|
|
|
test("runMigrations creates the admin and API-user schema idempotently", async (t) => {
|
|
await withTestDatabase(t, async ({ pool }) => {
|
|
await runMigrations(pool)
|
|
await runMigrations(pool)
|
|
const result = await pool.query(`
|
|
select table_name from information_schema.tables
|
|
where table_schema = current_schema()
|
|
order by table_name
|
|
`)
|
|
const names = result.rows.map((row) => row.table_name)
|
|
assert(names.includes("admin_sessions"))
|
|
assert(names.includes("api_users"))
|
|
assert(names.includes("api_keys"))
|
|
assert(names.includes("usage_events"))
|
|
assert(names.includes("message_logs"))
|
|
})
|
|
})
|