mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
609 lines
24 KiB
SQL
609 lines
24 KiB
SQL
-- ============================================================================
|
|
-- XAMXAM Database Schema — complete, fully migrated
|
|
-- Generated from local database on 2026-05-11
|
|
-- All 28 migrations merged into this single file.
|
|
-- ============================================================================
|
|
|
|
CREATE TABLE IF NOT EXISTS orientations (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS ap_programs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
code TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS finality_types (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS languages (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at TEXT DEFAULT NULL
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS format_types (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
sort_order INTEGER NOT NULL DEFAULT 99
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS tags (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
deleted_at TEXT DEFAULT NULL
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS access_types (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
description TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS license_types (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
description TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS authors (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL,
|
|
email TEXT,
|
|
show_contact INTEGER NOT NULL DEFAULT 0,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS supervisors (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name TEXT NOT NULL UNIQUE,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS theses (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
identifier TEXT,
|
|
title TEXT NOT NULL,
|
|
subtitle TEXT,
|
|
year INTEGER NOT NULL,
|
|
is_doctoral BOOLEAN DEFAULT 0,
|
|
objet TEXT NOT NULL DEFAULT 'tfe',
|
|
orientation_id INTEGER,
|
|
ap_program_id INTEGER,
|
|
finality_id INTEGER,
|
|
synopsis TEXT,
|
|
context_note TEXT,
|
|
remarks TEXT,
|
|
access_type_id INTEGER,
|
|
license_id INTEGER,
|
|
jury_points DECIMAL(4,2),
|
|
jury_note_added BOOLEAN DEFAULT 0,
|
|
submitted_at DATETIME,
|
|
defense_date DATETIME,
|
|
published_at DATETIME,
|
|
is_published BOOLEAN DEFAULT 0,
|
|
baiu_link TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
exemplaire_baiu INTEGER NOT NULL DEFAULT 0,
|
|
exemplaire_erg INTEGER NOT NULL DEFAULT 0,
|
|
cc2r INTEGER NOT NULL DEFAULT 0,
|
|
license_custom TEXT,
|
|
deleted_at TEXT DEFAULT NULL,
|
|
FOREIGN KEY (license_id) REFERENCES license_types(id),
|
|
FOREIGN KEY (access_type_id) REFERENCES access_types(id),
|
|
FOREIGN KEY (finality_id) REFERENCES finality_types(id),
|
|
FOREIGN KEY (ap_program_id) REFERENCES ap_programs(id),
|
|
FOREIGN KEY (orientation_id) REFERENCES orientations(id)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_authors (
|
|
thesis_id INTEGER NOT NULL,
|
|
author_id INTEGER NOT NULL,
|
|
author_order INTEGER DEFAULT 1,
|
|
PRIMARY KEY (thesis_id, author_id),
|
|
FOREIGN KEY (author_id) REFERENCES authors(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_supervisors (
|
|
thesis_id INTEGER NOT NULL,
|
|
supervisor_id INTEGER NOT NULL,
|
|
supervisor_order INTEGER DEFAULT 1,
|
|
role TEXT NOT NULL DEFAULT 'promoteur',
|
|
is_external INTEGER NOT NULL DEFAULT 0,
|
|
is_ulb INTEGER NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (thesis_id, supervisor_id),
|
|
FOREIGN KEY (supervisor_id) REFERENCES supervisors(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_languages (
|
|
thesis_id INTEGER NOT NULL,
|
|
language_id INTEGER NOT NULL,
|
|
PRIMARY KEY (thesis_id, language_id),
|
|
FOREIGN KEY (language_id) REFERENCES languages(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_formats (
|
|
thesis_id INTEGER NOT NULL,
|
|
format_id INTEGER NOT NULL,
|
|
PRIMARY KEY (thesis_id, format_id),
|
|
FOREIGN KEY (format_id) REFERENCES format_types(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_tags (
|
|
tag_id INTEGER NOT NULL,
|
|
thesis_id INTEGER NOT NULL,
|
|
PRIMARY KEY (tag_id, thesis_id),
|
|
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS thesis_files (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
thesis_id INTEGER NOT NULL,
|
|
file_type TEXT NOT NULL,
|
|
file_path TEXT NOT NULL,
|
|
file_name TEXT NOT NULL,
|
|
file_size INTEGER,
|
|
mime_type TEXT,
|
|
description TEXT,
|
|
uploaded_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
|
display_label TEXT,
|
|
file_hash TEXT,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS site_settings (
|
|
key TEXT PRIMARY KEY,
|
|
value TEXT NOT NULL DEFAULT '',
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS system_cache (
|
|
key TEXT PRIMARY KEY,
|
|
value TEXT NOT NULL,
|
|
updated_at INTEGER NOT NULL
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS pages (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
slug TEXT NOT NULL UNIQUE,
|
|
title TEXT NOT NULL,
|
|
content TEXT,
|
|
is_published BOOLEAN DEFAULT 1,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS share_links (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
slug TEXT NOT NULL UNIQUE,
|
|
objet_restriction TEXT,
|
|
password_hash TEXT,
|
|
is_active INTEGER NOT NULL DEFAULT 1,
|
|
usage_count INTEGER NOT NULL DEFAULT 0,
|
|
created_by INTEGER NOT NULL,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
expires_at DATETIME,
|
|
is_archived INTEGER NOT NULL DEFAULT 0,
|
|
name TEXT
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS smtp_settings (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
host TEXT NOT NULL DEFAULT '',
|
|
port INTEGER NOT NULL DEFAULT 587,
|
|
encryption TEXT NOT NULL DEFAULT 'tls',
|
|
username TEXT NOT NULL DEFAULT '',
|
|
password TEXT NOT NULL DEFAULT '',
|
|
from_email TEXT NOT NULL DEFAULT '',
|
|
from_name TEXT NOT NULL DEFAULT 'Post-ERG',
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
notify_email TEXT NOT NULL DEFAULT ''
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS apropos_contents (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
key TEXT NOT NULL UNIQUE,
|
|
value TEXT,
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS file_access_requests (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
thesis_id INTEGER NOT NULL,
|
|
email TEXT NOT NULL,
|
|
justification TEXT,
|
|
status TEXT NOT NULL DEFAULT 'pending',
|
|
admin_notes TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
approved_at DATETIME,
|
|
approved_by_admin_id INTEGER,
|
|
FOREIGN KEY (thesis_id) REFERENCES theses(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS file_access_tokens (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
request_id INTEGER NOT NULL,
|
|
token TEXT NOT NULL,
|
|
expires_at DATETIME NOT NULL,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
is_valid INTEGER NOT NULL DEFAULT 1,
|
|
used_at DATETIME DEFAULT NULL,
|
|
FOREIGN KEY (request_id) REFERENCES file_access_requests(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS file_access_sessions (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
request_id INTEGER NOT NULL,
|
|
session_token TEXT NOT NULL,
|
|
expires_at DATETIME NOT NULL,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
is_valid INTEGER NOT NULL DEFAULT 1,
|
|
FOREIGN KEY (request_id) REFERENCES file_access_requests(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS file_access_audit (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
request_id INTEGER NOT NULL,
|
|
event TEXT NOT NULL,
|
|
ip TEXT,
|
|
user_agent TEXT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (request_id) REFERENCES file_access_requests(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS form_help_blocks (
|
|
key TEXT PRIMARY KEY,
|
|
content TEXT NOT NULL DEFAULT '',
|
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
|
name TEXT NOT NULL DEFAULT '',
|
|
enabled INTEGER NOT NULL DEFAULT 1
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS admin_audit_log (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
ip TEXT NOT NULL,
|
|
user_agent TEXT,
|
|
resource TEXT NOT NULL,
|
|
action TEXT NOT NULL,
|
|
status TEXT NOT NULL,
|
|
context TEXT
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS peertube_settings (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
instance_url TEXT NOT NULL DEFAULT '',
|
|
channel_id INTEGER NOT NULL DEFAULT 1,
|
|
privacy INTEGER NOT NULL DEFAULT 1,
|
|
peertube_video_label TEXT NOT NULL DEFAULT '',
|
|
peertube_audio_label TEXT NOT NULL DEFAULT '',
|
|
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
channel_name TEXT NOT NULL DEFAULT ''
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS audit_log (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
timestamp TEXT NOT NULL DEFAULT (datetime('now')),
|
|
actor TEXT NOT NULL,
|
|
action TEXT NOT NULL,
|
|
table_name TEXT NOT NULL,
|
|
record_id INTEGER,
|
|
old_data TEXT,
|
|
new_data TEXT
|
|
);
|
|
|
|
-- ============================================================================
|
|
-- INDEXES
|
|
-- ============================================================================
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_admin_audit_log_action ON admin_audit_log(action);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_admin_audit_log_created_at ON admin_audit_log(created_at);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_admin_audit_log_resource ON admin_audit_log(resource);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_table_record ON audit_log(table_name, record_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_timestamp ON audit_log(timestamp);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_authors_email ON authors(email);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_audit_request
|
|
ON file_access_audit(request_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_requests_email
|
|
ON file_access_requests(email);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_requests_status
|
|
ON file_access_requests(status);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_requests_thesis_id
|
|
ON file_access_requests(thesis_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_sessions_expires
|
|
ON file_access_sessions(expires_at);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_sessions_token
|
|
ON file_access_sessions(session_token);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_tokens_expires_at
|
|
ON file_access_tokens(expires_at);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_file_access_tokens_token
|
|
ON file_access_tokens(token);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_share_links_active ON share_links(is_active);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_share_links_archived ON share_links(is_archived);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_share_links_slug ON share_links(slug);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_tags_name ON tags(name);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_access_type ON theses(access_type_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_ap_program ON theses(ap_program_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_identifier ON theses(identifier);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_orientation ON theses(orientation_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_pub_year ON theses(is_published, year DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_published ON theses(is_published);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_theses_year ON theses(year);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_thesis_authors_author ON thesis_authors(author_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_thesis_authors_thesis ON thesis_authors(thesis_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_thesis_tags_tag ON thesis_tags(tag_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_thesis_tags_thesis ON thesis_tags(thesis_id);
|
|
|
|
-- ============================================================================
|
|
-- VIEWS
|
|
-- ============================================================================
|
|
|
|
CREATE VIEW IF NOT EXISTS v_smtp_active AS
|
|
SELECT * FROM smtp_settings WHERE id = 1;
|
|
|
|
CREATE VIEW IF NOT EXISTS v_theses_full AS
|
|
SELECT
|
|
t.id,
|
|
t.identifier,
|
|
t.title,
|
|
t.subtitle,
|
|
t.year,
|
|
t.is_doctoral,
|
|
t.objet,
|
|
o.name as orientation,
|
|
ap.name as ap_program,
|
|
ft.name as finality_type,
|
|
t.synopsis,
|
|
t.context_note,
|
|
at.name as access_type,
|
|
lt.name as license_type,
|
|
t.license_id,
|
|
t.license_custom,
|
|
t.access_type_id,
|
|
t.jury_points,
|
|
t.submitted_at,
|
|
t.defense_date,
|
|
t.published_at,
|
|
t.is_published,
|
|
t.baiu_link,
|
|
t.exemplaire_baiu,
|
|
t.exemplaire_erg,
|
|
t.cc2r,
|
|
t.remarks,
|
|
t.jury_note_added,
|
|
GROUP_CONCAT(DISTINCT a.name ORDER BY a.name ASC) as authors,
|
|
GROUP_CONCAT(DISTINCT s.name) as supervisors,
|
|
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'president' THEN s.name END) as jury_president,
|
|
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'promoteur' AND ts.is_ulb = 0 THEN s.name END) as jury_promoteurs,
|
|
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'promoteur' AND ts.is_ulb = 1 THEN s.name END) as jury_promoteurs_ulb,
|
|
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'lecteur' AND ts.is_external = 0 THEN s.name END) as jury_lecteurs_internes,
|
|
GROUP_CONCAT(DISTINCT CASE WHEN ts.role = 'lecteur' AND ts.is_external = 1 THEN s.name END) as jury_lecteurs_externes,
|
|
GROUP_CONCAT(DISTINCT UPPER(SUBSTR(l.name,1,1)) || SUBSTR(l.name,2)) as languages,
|
|
GROUP_CONCAT(DISTINCT fmt.name) as formats,
|
|
GROUP_CONCAT(DISTINCT tg.name) as keywords,
|
|
(SELECT a2.email FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as contact_interne,
|
|
(SELECT a2.show_contact FROM authors a2 JOIN thesis_authors ta2 ON a2.id = ta2.author_id WHERE ta2.thesis_id = t.id ORDER BY ta2.author_order LIMIT 1) as contact_public
|
|
FROM theses t
|
|
LEFT JOIN orientations o ON t.orientation_id = o.id
|
|
LEFT JOIN ap_programs ap ON t.ap_program_id = ap.id
|
|
LEFT JOIN finality_types ft ON t.finality_id = ft.id
|
|
LEFT JOIN access_types at ON t.access_type_id = at.id
|
|
LEFT JOIN license_types lt ON t.license_id = lt.id
|
|
LEFT JOIN thesis_authors ta ON t.id = ta.thesis_id
|
|
LEFT JOIN authors a ON ta.author_id = a.id
|
|
LEFT JOIN thesis_supervisors ts ON t.id = ts.thesis_id
|
|
LEFT JOIN supervisors s ON ts.supervisor_id = s.id
|
|
LEFT JOIN thesis_languages tl ON t.id = tl.thesis_id
|
|
LEFT JOIN languages l ON tl.language_id = l.id
|
|
LEFT JOIN thesis_formats tf ON t.id = tf.thesis_id
|
|
LEFT JOIN format_types fmt ON tf.format_id = fmt.id
|
|
LEFT JOIN thesis_tags tt ON t.id = tt.thesis_id
|
|
LEFT JOIN tags tg ON tt.tag_id = tg.id
|
|
GROUP BY t.id;
|
|
|
|
CREATE VIEW IF NOT EXISTS v_theses_public AS
|
|
SELECT * FROM v_theses_full
|
|
WHERE is_published = 1;
|
|
|
|
-- ============================================================================
|
|
-- TRIGGERS
|
|
-- ============================================================================
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_apropos_contents_timestamp
|
|
AFTER UPDATE ON apropos_contents
|
|
BEGIN
|
|
UPDATE apropos_contents SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_authors_timestamp
|
|
AFTER UPDATE ON authors
|
|
BEGIN
|
|
UPDATE authors SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_form_help_blocks_timestamp
|
|
AFTER UPDATE ON form_help_blocks
|
|
BEGIN
|
|
UPDATE form_help_blocks SET updated_at = CURRENT_TIMESTAMP WHERE key = NEW.key;
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_pages_timestamp
|
|
AFTER UPDATE ON pages
|
|
BEGIN
|
|
UPDATE pages SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_supervisors_timestamp
|
|
AFTER UPDATE ON supervisors
|
|
BEGIN
|
|
UPDATE supervisors SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS update_theses_timestamp
|
|
AFTER UPDATE ON theses
|
|
BEGIN
|
|
UPDATE theses SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
|
END;
|
|
|
|
-- ============================================================================
|
|
-- SEED DATA (reference data + initial settings)
|
|
-- ============================================================================
|
|
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Arts Numériques');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Bande-Dessinée');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Cinéma d''animation');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Design Numérique');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Dessin');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Graphisme');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Gravure');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Illustration');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Installation-Performance');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Peinture');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Photographie');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Sculpture');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Sérigraphie');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Typographie');
|
|
INSERT OR IGNORE INTO orientations (name) VALUES ('Vidéographie');
|
|
|
|
INSERT OR IGNORE INTO ap_programs (name, code) VALUES ('Narration Spéculative', 'NS');
|
|
INSERT OR IGNORE INTO ap_programs (name, code) VALUES ('Design et Politique du Multiple', 'DPM');
|
|
INSERT OR IGNORE INTO ap_programs (name, code) VALUES ('Atelier Pratiques Situées', 'APS');
|
|
INSERT OR IGNORE INTO ap_programs (name, code) VALUES ('Lieux, Interdisciplinarités, Écologie, Nécessité, Systèmes', 'LIENS');
|
|
INSERT OR IGNORE INTO ap_programs (name, code) VALUES ('Pratique de l''art - outils critiques, arts et contexte simultanés', 'PACS');
|
|
|
|
INSERT OR IGNORE INTO finality_types (name) VALUES ('Approfondi');
|
|
INSERT OR IGNORE INTO finality_types (name) VALUES ('Enseignement');
|
|
INSERT OR IGNORE INTO finality_types (name) VALUES ('Spécialisé');
|
|
|
|
INSERT OR IGNORE INTO languages (name) VALUES ('français');
|
|
INSERT OR IGNORE INTO languages (name) VALUES ('anglais');
|
|
INSERT OR IGNORE INTO languages (name) VALUES ('néerlandais');
|
|
INSERT OR IGNORE INTO languages (name) VALUES ('italian');
|
|
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Site web', 5);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Audio', 3);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Vidéo', 4);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Performance', 6);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Objet éditorial', 7);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Installation', 8);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Autre', 9);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Écriture', 1);
|
|
INSERT OR IGNORE INTO format_types (name, sort_order) VALUES ('Image', 2);
|
|
|
|
INSERT OR IGNORE INTO access_types (name, description) VALUES ('Libre', 'TFE en libre accès à tout le monde sur la plateforme et en bibliothèque');
|
|
INSERT OR IGNORE INTO access_types (name, description) VALUES ('Interne', 'TFE accessible uniquement sur place en physique. Une note descriptive est disponible sur le site');
|
|
INSERT OR IGNORE INTO access_types (name, description) VALUES ('Interdit', 'TFE non disponible en physique ni sur le site. Une note descriptive est disponible sur le site');
|
|
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY-NC 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY-NC-ND 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY-NC-SA 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY-ND 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('CC BY-SA 4.0');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('Domaine public');
|
|
INSERT OR IGNORE INTO license_types (name) VALUES ('Tous droits réservés');
|
|
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('access_type_interdit_enabled', '1');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('access_type_interne_enabled', '1');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('access_type_libre_enabled', '0');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('objet_frart_enabled', '0');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('objet_these_enabled', '0');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('peertube_upload_enabled', '1');
|
|
INSERT OR IGNORE INTO site_settings (key, value) VALUES ('restricted_files_enabled', '1');
|
|
|
|
INSERT OR IGNORE INTO pages (slug, title, content, is_published) VALUES ('about', 'À propos', 'Contenu à venir', 1);
|
|
INSERT OR IGNORE INTO pages (slug, title, content, is_published) VALUES ('charte', 'Charte', 'Contenu à venir', 1);
|
|
INSERT OR IGNORE INTO pages (slug, title, content, is_published) VALUES ('licenses', 'Licences', 'Contenu à venir', 1);
|
|
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('partage_intro', 'Introduction', 'Hahahaha
|
|
## Beware the dog', 0, 0);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_tfe_info', 'Informations du TFE', 'Hello world', 0, 1);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_synopsis', 'Note Synopsis', '', 0, 2);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_jury', 'Composition du jury', '', 0, 3);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_academic', 'Cadre académique', '', 0, 4);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_files', 'Fichiers', '', 1, 5);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_access', 'Visibilité / Accès', 'qsldkjlfkjdsqmflkjq', 1, 6);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_email', 'E-mail de confirmation', '', 0, 7);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_languages', 'Langue(s)', 'Hahah', 0, 0);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_keywords', 'Mots-clés', 'lolz', 0, 0);
|
|
INSERT OR IGNORE INTO form_help_blocks (key, name, content, enabled, sort_order) VALUES ('fieldset_metadata', 'Métadonnées complémentaires', '', 0, 0);
|
|
|
|
INSERT OR IGNORE INTO apropos_contents (key, value) VALUES ('contacts', '[
|
|
{
|
|
"role": "Bibliothèque d''architecture, d''ingénierie architecturale, d''urbanisme (BAIU) :",
|
|
"entries": [
|
|
{"text": "Laurent Leprince", "url": "", "email": "laurent.leprince@uclouvain.be"}
|
|
]
|
|
},
|
|
{
|
|
"role": "Responsable des mémoires de l''ERG :",
|
|
"entries": [
|
|
{"text": "Xavier Gorgol", "url": "", "email": "xavier.gorgol@erg.be"}
|
|
]
|
|
},
|
|
{
|
|
"role": "Cours de suivi de mémoire :",
|
|
"entries": [
|
|
{"text": "Brigitte Ledune", "url": "", "email": "brigitte.ledune@erg.be"}
|
|
]
|
|
}
|
|
]');
|
|
|
|
-- Singleton table placeholders
|
|
INSERT OR IGNORE INTO smtp_settings (id) VALUES (1);
|
|
INSERT OR IGNORE INTO peertube_settings (id) VALUES (1);
|
|
|
|
-- ============================================================================
|
|
-- END OF SCHEMA
|
|
-- ============================================================================
|