update schema test and minify migration
Sonarqube Scanner / Build and analyze (push) Failing after 1m7s
Sonarqube Scanner / Build and analyze (push) Failing after 1m7s
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
-- Ergänzt den manuellen Freigabezeitpunkt für Strecken.
|
-- Ergänzt den manuellen Freigabezeitpunkt für Strecken.
|
||||||
-- Neue Strecken bleiben unveröffentlicht, solange activated_at is NULL.
|
-- Neue Strecken bleiben unveröffentlicht, solange activated_at is NULL.
|
||||||
ALTER TABLE routes ADD COLUMN activated_at TEXT NULL DEFAULT NULL;
|
ALTER TABLE routes ADD COLUMN activated_at TEXT DEFAULT NULL;
|
||||||
@@ -12,10 +12,13 @@ async function read(relativePath) {
|
|||||||
test('initial database schema creates routes with a nullable activation timestamp', async () => {
|
test('initial database schema creates routes with a nullable activation timestamp', async () => {
|
||||||
const schema = await read('database/schema.sql');
|
const schema = await read('database/schema.sql');
|
||||||
const migration = await read('database/migrations/20260901_add_route_activated_at.sql');
|
const migration = await read('database/migrations/20260901_add_route_activated_at.sql');
|
||||||
const routeTable = schema.match(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?routes\s*\([\s\S]*?\);/i);
|
const routeTable = schema.match(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?routes\s*\([\s\S]*?\)\s+STRICT\s*;/i);
|
||||||
|
|
||||||
assert.ok(routeTable, 'database/schema.sql must define the routes table');
|
assert.ok(routeTable, 'database/schema.sql must define the routes table as a STRICT SQLite table');
|
||||||
assert.match(routeTable[0], /\bactivated_at\s+DATETIME\s+NULL\b/i);
|
assert.match(routeTable[0], /\bactivated_at\s+TEXT\s+(?:NULL\s+)?DEFAULT\s+NULL\b/i);
|
||||||
assert.match(migration, /ALTER\s+TABLE\s+routes\s+ADD\s+COLUMN\s+activated_at\s+DATETIME\s+NULL/i);
|
assert.doesNotMatch(routeTable[0], /\bactivated_at\s+DATETIME\b/i);
|
||||||
|
|
||||||
|
assert.match(migration, /ALTER\s+TABLE\s+routes\s+ADD\s+COLUMN\s+activated_at\s+TEXT\s+(?:NULL\s+)?DEFAULT\s+NULL/i);
|
||||||
|
assert.doesNotMatch(migration, /\bactivated_at\s+DATETIME\b/i);
|
||||||
assert.match(migration, /Neue Strecken bleiben unveröffentlicht|unpublished|activated_at is NULL/i);
|
assert.match(migration, /Neue Strecken bleiben unveröffentlicht|unpublished|activated_at is NULL/i);
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user