import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import path from 'node:path'; import test from 'node:test'; const root = path.resolve(import.meta.dirname, '..'); async function read(relativePath) { return fs.readFile(path.join(root, relativePath), 'utf8'); } test('initial database schema creates routes with a nullable activation timestamp', async () => { const schema = await read('database/schema.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]*?\)\s+STRICT\s*;/i); assert.ok(routeTable, 'database/schema.sql must define the routes table as a STRICT SQLite table'); assert.match(routeTable[0], /\bactivated_at\s+TEXT\s+(?:NULL\s+)?DEFAULT\s+NULL\b/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); });