feat(db): migrazioni ruoli editor->superuser, guid contenuti, posts.author_id

This commit is contained in:
2026-07-05 21:40:28 +02:00
parent d4cf359805
commit 5cea895d51
3 changed files with 57 additions and 4 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
import type Database from 'better-sqlite3';
import { randomUUID } from 'node:crypto';
import { getDb } from './db';
import { contentSeed, seedByTag, type ContentType } from '../data/content-seed';
import { stylesToClasses } from './style-presets';
@@ -6,8 +7,8 @@ import { stylesToClasses } from './style-presets';
interface Entry { value: string; type: ContentType; styles: Record<string, string> }
export function syncSeed(db: Database.Database): void {
const ins = db.prepare('INSERT OR IGNORE INTO content_blocks (tag, type, value) VALUES (?, ?, ?)');
const tx = db.transaction(() => { for (const e of contentSeed) ins.run(e.tag, e.type, e.value); });
const ins = db.prepare('INSERT OR IGNORE INTO content_blocks (tag, type, value, guid) VALUES (?, ?, ?, ?)');
const tx = db.transaction(() => { for (const e of contentSeed) ins.run(e.tag, e.type, e.value, randomUUID()); });
tx();
}