-- Add global, versioned service terms and privacy-policy content. -- Content is shared by every configured domain; the site name is substituted -- when the published document is rendered. CREATE TABLE IF NOT EXISTS `legal_documents` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `slug` varchar(32) NOT NULL, `locale` varchar(10) NOT NULL, `title` varchar(120) NOT NULL, `draft_html` longtext NOT NULL, `effective_date` date NOT NULL, `draft_version` int(10) UNSIGNED NOT NULL DEFAULT 0, `published_revision_id` bigint(20) UNSIGNED DEFAULT NULL, `updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uniq_legal_document_slug_locale` (`slug`,`locale`), KEY `idx_legal_document_published_revision` (`published_revision_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE IF NOT EXISTS `legal_document_revisions` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `document_id` bigint(20) UNSIGNED NOT NULL, `version` int(10) UNSIGNED NOT NULL, `title` varchar(120) NOT NULL, `content_html` longtext NOT NULL, `effective_date` date NOT NULL, `published_at` datetime NOT NULL, `published_by` bigint(20) UNSIGNED NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uniq_legal_document_revision` (`document_id`,`version`), KEY `idx_legal_revision_published` (`document_id`,`published_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;