diff --git a/drizzle/0036_broken_rattler.sql b/drizzle/0036_broken_rattler.sql index a98f2aa..ab22549 100644 --- a/drizzle/0036_broken_rattler.sql +++ b/drizzle/0036_broken_rattler.sql @@ -1,4 +1,4 @@ -CREATE TABLE `webImportSources` ( +CREATE TABLE IF NOT EXISTS `webImportSources` ( `id` int AUTO_INCREMENT NOT NULL, `userId` int NOT NULL, `name` varchar(100) NOT NULL, diff --git a/server/webImportSourcesMigration.test.ts b/server/webImportSourcesMigration.test.ts new file mode 100644 index 0000000..caf04b6 --- /dev/null +++ b/server/webImportSourcesMigration.test.ts @@ -0,0 +1,21 @@ +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; +import { describe, expect, it } from "vitest"; + +const migration = readFileSync( + resolve(process.cwd(), "drizzle/0036_broken_rattler.sql"), + "utf8", +); + +describe("webImportSources migration", () => { + it("peut être appliquée sans échec si la table a déjà été créée", () => { + expect(migration).toMatch(/CREATE TABLE IF NOT EXISTS `webImportSources`/); + }); + + it("définit les colonnes nécessaires au connecteur sans modifier les factures", () => { + expect(migration).toContain("`portalUrl` varchar(500) NOT NULL"); + expect(migration).toContain("`loginPassword` text NOT NULL"); + expect(migration).toContain("`apiToken` varchar(128) NOT NULL"); + expect(migration).not.toContain("invoices"); + }); +});