fix: rendre la migration des connecteurs idempotente
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE `webImportSources` (
|
CREATE TABLE IF NOT EXISTS `webImportSources` (
|
||||||
`id` int AUTO_INCREMENT NOT NULL,
|
`id` int AUTO_INCREMENT NOT NULL,
|
||||||
`userId` int NOT NULL,
|
`userId` int NOT NULL,
|
||||||
`name` varchar(100) NOT NULL,
|
`name` varchar(100) NOT NULL,
|
||||||
|
|||||||
21
server/webImportSourcesMigration.test.ts
Normal file
21
server/webImportSourcesMigration.test.ts
Normal 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");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user