fix: preserve legacy accounting migration data
This commit is contained in:
1 parent
3de1530074
commit
3cdca5c82c
10 files changed
+559
-177
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
const migration = await readFile(
|
||||
path.join(process.cwd(), "drizzle/0002_accounting_intents.sql"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("0002 retains legacy Immich text and gates only new non-canonical rows", () => {
|
||||
expect(migration).not.toMatch(/ALTER COLUMN "immich_[^"]+" SET DATA TYPE uuid/);
|
||||
expect(migration).toContain(
|
||||
'ADD CONSTRAINT "album_grants_canonical_immich_album_id_check"',
|
||||
);
|
||||
expect(migration).toContain(
|
||||
'ADD CONSTRAINT "usages_canonical_immich_asset_id_check"',
|
||||
);
|
||||
expect(migration).toContain(
|
||||
'ADD CONSTRAINT "usages_canonical_immich_album_id_check"',
|
||||
);
|
||||
expect(migration).toContain(
|
||||
'ADD CONSTRAINT "download_events_canonical_immich_asset_id_check"',
|
||||
);
|
||||
expect(migration.match(/NOT VALID/g)).toHaveLength(4);
|
||||
});
|
||||
|
||||
test("0002 uses an explicit legacy kind instead of random UUID ordering for ambiguity", () => {
|
||||
expect(migration).not.toContain('ORDER BY "authorized_at", "id"');
|
||||
expect(migration).toContain("ELSE 'legacy'");
|
||||
expect(migration).toContain("in ('new_usage', 'repeat_download', 'legacy')");
|
||||
expect(migration).toContain("case_colliding_idempotency_keys");
|
||||
});
|
||||
Reference in new issue
Block a user