feat(db): Implement schema migrations and add Projects section
Introduces a custom migration system for SQLite, allowing incremental and safe schema evolution. Adds a new 'Projects' section to the CV, including database tables, public UI, and full management in the admin dashboard with live editing, drag-and-drop reordering, and collapsible forms. Updates: - and for schema management. - with script. - to use migrations. - to rely on migrations. - and for new project data operations. - and for Projects UI. - and to integrate the Projects section. Also updates: - to automatically import Keycloak realm on startup. - for the Elysia app build. - with refined print styles (omitting socials and about).
This commit is contained in:
54
src/db/migrations/001_baseline.ts
Normal file
54
src/db/migrations/001_baseline.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
|
||||
export function up(db: Database) {
|
||||
db.run("PRAGMA foreign_keys = ON;");
|
||||
|
||||
db.run(`CREATE TABLE IF NOT EXISTS languages (code TEXT PRIMARY KEY);`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS profile (
|
||||
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||
email TEXT NOT NULL,
|
||||
phone TEXT,
|
||||
website TEXT,
|
||||
github_url TEXT,
|
||||
linkedin_url TEXT,
|
||||
avatar_url TEXT
|
||||
);
|
||||
`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS profile_translations (
|
||||
profile_id INTEGER NOT NULL,
|
||||
language_code TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
job_title TEXT NOT NULL,
|
||||
summary TEXT,
|
||||
location TEXT,
|
||||
PRIMARY KEY (profile_id, language_code),
|
||||
FOREIGN KEY (profile_id) REFERENCES profile(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (language_code) REFERENCES languages(code)
|
||||
);
|
||||
`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS skills (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
category TEXT NOT NULL,
|
||||
icon TEXT,
|
||||
display_order INTEGER DEFAULT 0
|
||||
);
|
||||
`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS skill_translations (
|
||||
skill_id INTEGER NOT NULL,
|
||||
language_code TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
category_display TEXT,
|
||||
PRIMARY KEY (skill_id, language_code),
|
||||
FOREIGN KEY (skill_id) REFERENCES skills(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (language_code) REFERENCES languages(code)
|
||||
);
|
||||
`);
|
||||
}
|
||||
Reference in New Issue
Block a user