import { describe, expect, it } from "vitest"; import { createReadyDb, readDownSql } from "../helpers/world"; describe("migrations", () => { it("sobe do zero e o rollback remove as tabelas do módulo", async () => { const db = await createReadyDb(); const tables = await db.withService((query) => query.query<{ table_name: string }>( `select table_name from information_schema.tables where table_schema = 'public' and table_name like 'spreadsheet_%'`, ), ); expect(tables.map((row) => row.table_name).sort()).toEqual([ "spreadsheet_adapter_settings", "spreadsheet_job_mappings", "spreadsheet_job_sources", "spreadsheet_jobs", "spreadsheet_models", ]); await db.exec(await readDownSql()); const after = await db.withService((query) => query.query<{ table_name: string }>( `select table_name from information_schema.tables where table_schema = 'public' and table_name like 'spreadsheet_%'`, ), ); expect(after).toHaveLength(0); const profiles = await db.withService((query) => query.query(`select id from public.profiles`)); expect(profiles.length).toBe(5); await db.close(); }); });