fix: rendre la migration des connecteurs idempotente

This commit is contained in:
Manus
2026-09-30 13:26:31 +00:00
committed by manus-admin
parent 77d57f4e42
commit 343ad71a59
2 changed files with 22 additions and 1 deletions

View File

@@ -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,

View File

@@ -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");
});
});