fix: add missing remote DB migrations and deploy-migrate recipe

Four ALTER TABLE / CREATE TABLE statements were applied locally but never
deployed to the remote production database, causing:

- acces.php → 500: share_links.is_archived missing (ShareLink::listActive/listArchived)
- parametres.php → 500: smtp_settings.notify_email missing (SmtpRelay::getSettings)
- /tfe?id=N → redirect-to-home: thesis_files.sort_order missing (getThesisFiles ORDER BY)
- admin_audit_log table missing (AdminLogger::insertDb, best-effort but noisy)

Adds four pending migrations (008–011) covering all missing schema changes.
Adds 'deploy-migrate' just recipe to run migrations on the remote after deploy.
This commit is contained in:
Pontoporeia
2026-05-04 18:19:26 +02:00
parent ae6d9b86b3
commit 37111eaac4
8 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
-- Migration 008: add is_archived to share_links
-- Required by ShareLink::listActive() / listArchived() / archive() / validateLink().
ALTER TABLE share_links ADD COLUMN is_archived INTEGER NOT NULL DEFAULT 0;
CREATE INDEX IF NOT EXISTS idx_share_links_archived ON share_links(is_archived);

View File

@@ -0,0 +1,18 @@
-- Migration 009: create admin_audit_log table
-- Mirrors every admin action logged to /var/log/xamxam.log.
-- Best-effort: application never fails if this table is absent, but the
-- table must exist for AdminLogger::insertDb() to write audit records.
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 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_admin_audit_log_action ON admin_audit_log(action);

View File

@@ -0,0 +1,4 @@
-- Migration 010: add notify_email to smtp_settings
-- Required by SmtpRelay::getSettings() which SELECTs this column.
-- Absence of this column causes a fatal SQL error on parametres.php.
ALTER TABLE smtp_settings ADD COLUMN notify_email TEXT NOT NULL DEFAULT '';

View File

@@ -0,0 +1,5 @@
-- Migration 011: add sort_order and display_label to thesis_files
-- Required by Database::getThesisFiles() which runs ORDER BY sort_order.
-- Absence of sort_order causes a fatal SQL error on every public TFE detail page.
ALTER TABLE thesis_files ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0;
ALTER TABLE thesis_files ADD COLUMN display_label TEXT;

View File

@@ -1 +1,4 @@
{"timestamp":"2026-05-04T15:36:30+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0","resource":"system","action":"maintenance_on","status":"success"}
{"timestamp":"2026-05-04T15:53:38+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0","resource":"system","action":"maintenance_off","status":"success"}
{"timestamp":"2026-05-04T15:53:44+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0","resource":"system","action":"maintenance_on","status":"success"}
{"timestamp":"2026-05-04T16:11:57+00:00","ip":"127.0.0.1","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0","resource":"system","action":"maintenance_off","status":"success"}

View File

@@ -1 +0,0 @@
2026-05-04T15:36:30+00:00