-- Form help blocks: stores per-fieldset student-facing explanatory text
-- displayed in the /partage share-link submission form.
-- Each row is keyed by a stable slug matching TODO locations in partage/index.php.

CREATE TABLE IF NOT EXISTS form_help_blocks (
    key        TEXT PRIMARY KEY,
    content    TEXT NOT NULL DEFAULT '',
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

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;

-- Seed the eight block slots referenced in partage/index.php.
INSERT OR IGNORE INTO form_help_blocks (key, content) VALUES
    ('partage_intro',     ''),
    ('fieldset_tfe_info', ''),
    ('fieldset_synopsis', ''),
    ('fieldset_jury',     ''),
    ('fieldset_academic', ''),
    ('fieldset_files',    ''),
    ('fieldset_access',   ''),
    ('fieldset_email',    '');
