-- Secure meeting document slots. Legacy meetings.summons_url and toast_list_url remain readable.
CREATE TABLE IF NOT EXISTS meeting_document_slots (
 meeting_id BIGINT UNSIGNED NOT NULL,
 document_type ENUM('summons','toast_list') NOT NULL,
 document_id BIGINT UNSIGNED NOT NULL,
 created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
 updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (meeting_id,document_type),
 UNIQUE KEY uq_meeting_document_slot_document (document_id),
 CONSTRAINT fk_meeting_document_slot_meeting FOREIGN KEY (meeting_id) REFERENCES meetings(id) ON DELETE CASCADE,
 CONSTRAINT fk_meeting_document_slot_document FOREIGN KEY (document_id) REFERENCES tenant_documents(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO migration_history(version,name,checksum,execution_ms)
VALUES('202610010067','Secure meeting summons and toast-list document slots',SHA2('202610010067_meeting_document_slots_v1',256),0)
ON DUPLICATE KEY UPDATE name=VALUES(name),checksum=VALUES(checksum);
