import { describe, expect, test } from "bun:test"; describe("share migration", () => { test("backfills Discord IDs before creating the unique index", async () => { const migration = await Bun.file( new URL("../../drizzle/0018_authenticated_share.sql", import.meta.url) ).text(); const backfill = migration.indexOf('SET "discord_id"'); const uniqueIndex = migration.indexOf( 'CREATE UNIQUE INDEX "user_discord_id_unique"' ); expect(backfill).toBeGreaterThan(-1); expect(uniqueIndex).toBeGreaterThan(backfill); expect(migration).toContain('CREATE TABLE "share"."text"'); expect(migration).toContain('CREATE TABLE "share"."comment"'); expect(migration).toContain("ON DELETE cascade"); }); });