|
|
|
|
@ -66,6 +66,161 @@ CREATE TABLE `legal_document_revisions` (
|
|
|
|
|
`published_by` bigint(20) UNSIGNED NOT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `ui_copy_locales` (
|
|
|
|
|
`id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`locale` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`display_name` varchar(128) NOT NULL,
|
|
|
|
|
`enabled` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`source_claim` tinyint(1) UNSIGNED DEFAULT NULL,
|
|
|
|
|
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
CONSTRAINT `chk_ui_copy_locale_shape` CHECK (
|
|
|
|
|
`locale` REGEXP '^[A-Za-z0-9]{2,16}(-[A-Za-z0-9]{2,16})*$'
|
|
|
|
|
AND `enabled` IN (0,1)
|
|
|
|
|
AND (`source_claim` IS NULL OR `source_claim` = 1)
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `ui_copy_entries` (
|
|
|
|
|
`id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`copy_key` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`scope` varchar(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`page_key` varchar(96) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`location` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`kind` varchar(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`format` varchar(24) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'plain_text',
|
|
|
|
|
`criticality` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'normal',
|
|
|
|
|
`required` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`allow_hide` tinyint(1) UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
`max_length` int(10) UNSIGNED NOT NULL DEFAULT 4096,
|
|
|
|
|
`source_text_zh` longtext NOT NULL,
|
|
|
|
|
`source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`placeholder_contract_json` mediumtext NOT NULL,
|
|
|
|
|
`placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`manifest_revision` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
`state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'active',
|
|
|
|
|
`first_seen_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`last_seen_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
CONSTRAINT `chk_ui_copy_entry_shape` CHECK (
|
|
|
|
|
`copy_key` <> '' AND `scope` <> '' AND `page_key` <> ''
|
|
|
|
|
AND `location` <> '' AND `kind` <> ''
|
|
|
|
|
AND `format` IN ('plain_text','icu')
|
|
|
|
|
AND `criticality` IN ('normal','required','critical')
|
|
|
|
|
AND `required` IN (0,1) AND `allow_hide` IN (0,1)
|
|
|
|
|
AND (`required` = 0 OR `allow_hide` = 0)
|
|
|
|
|
AND (`criticality` = 'normal' OR `allow_hide` = 0)
|
|
|
|
|
AND `max_length` BETWEEN 1 AND 20000
|
|
|
|
|
AND `source_hash_zh` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `placeholder_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `manifest_revision` > 0
|
|
|
|
|
AND `state` IN ('active','orphaned')
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `ui_copy_drafts` (
|
|
|
|
|
`id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`entry_id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`locale_id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`draft_text` longtext NOT NULL,
|
|
|
|
|
`draft_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`visibility` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'visible',
|
|
|
|
|
`translated_source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`translated_placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`draft_version` bigint(20) UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
`validation_state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'pending',
|
|
|
|
|
`validation_errors_json` mediumtext NOT NULL,
|
|
|
|
|
`created_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_by` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
CONSTRAINT `chk_ui_copy_draft_shape` CHECK (
|
|
|
|
|
`draft_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `translated_source_hash_zh` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `translated_placeholder_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `visibility` IN ('visible','hidden')
|
|
|
|
|
AND `draft_version` > 0
|
|
|
|
|
AND `validation_state` IN ('pending','valid','invalid','stale')
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `ui_copy_publications` (
|
|
|
|
|
`id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`publication_key` char(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`locale_id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`revision` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`catalog_generation` char(66) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`previous_publication_id` bigint(20) UNSIGNED DEFAULT NULL,
|
|
|
|
|
`manifest_revision` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`manifest_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`catalog_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
`artifact_path` varchar(512) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
`entry_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`state` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'preparing',
|
|
|
|
|
`request_idempotency_key` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`request_fingerprint` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`requested_by` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`published_by` bigint(20) UNSIGNED DEFAULT NULL,
|
|
|
|
|
`prepared_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`published_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`error_code` varchar(128) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
`updated_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
CONSTRAINT `chk_ui_copy_publication_identity` CHECK (
|
|
|
|
|
`publication_key` REGEXP '^[a-f0-9]{32}$'
|
|
|
|
|
AND `revision` > 0
|
|
|
|
|
AND `catalog_generation` REGEXP '^g-[a-f0-9]{64}$'
|
|
|
|
|
AND `manifest_revision` > 0
|
|
|
|
|
AND `manifest_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `request_idempotency_key` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `request_fingerprint` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT `chk_ui_copy_publication_terminal` CHECK (
|
|
|
|
|
(`state` = 'preparing' AND `catalog_hash` = ''
|
|
|
|
|
AND `artifact_path` = '' AND `published_by` IS NULL
|
|
|
|
|
AND `published_at` = 0
|
|
|
|
|
AND `error_code` = '')
|
|
|
|
|
OR (`state` = 'ready'
|
|
|
|
|
AND `catalog_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `artifact_path` <> '' AND `published_by` IS NOT NULL
|
|
|
|
|
AND `prepared_at` > 0 AND `published_at` > 0
|
|
|
|
|
AND `error_code` = '')
|
|
|
|
|
OR (`state` = 'failed' AND `published_by` IS NULL
|
|
|
|
|
AND `published_at` = 0 AND `error_code` <> '')
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `ui_copy_revision_items` (
|
|
|
|
|
`id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`publication_id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`entry_id` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`copy_key` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`source_text_zh` longtext NOT NULL,
|
|
|
|
|
`published_text` longtext NOT NULL,
|
|
|
|
|
`visibility` varchar(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`source_hash_zh` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`placeholder_contract_json` mediumtext NOT NULL,
|
|
|
|
|
`placeholder_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`published_hash` char(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
`manifest_revision` bigint(20) UNSIGNED NOT NULL,
|
|
|
|
|
`draft_version` bigint(20) UNSIGNED DEFAULT NULL,
|
|
|
|
|
`created_at` bigint(20) UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
CONSTRAINT `chk_ui_copy_revision_item_shape` CHECK (
|
|
|
|
|
`copy_key` <> ''
|
|
|
|
|
AND `visibility` IN ('visible','hidden')
|
|
|
|
|
AND `source_hash_zh` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `placeholder_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `published_hash` REGEXP '^[a-f0-9]{64}$'
|
|
|
|
|
AND `manifest_revision` > 0
|
|
|
|
|
AND (`draft_version` IS NULL OR `draft_version` > 0)
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE `coupon` (
|
|
|
|
|
`id` bigint(20) NOT NULL,
|
|
|
|
|
`code` text NOT NULL,
|
|
|
|
|
@ -518,6 +673,40 @@ ALTER TABLE `legal_document_revisions`
|
|
|
|
|
ADD UNIQUE KEY `uniq_legal_document_revision` (`document_id`,`version`),
|
|
|
|
|
ADD KEY `idx_legal_revision_published` (`document_id`,`published_at`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_locales`
|
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_locale_name` (`locale`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_locale_source` (`source_claim`),
|
|
|
|
|
ADD KEY `ui_copy_locale_enabled` (`enabled`,`locale`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_entries`
|
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_entry_key` (`copy_key`),
|
|
|
|
|
ADD KEY `ui_copy_entry_page` (`page_key`,`state`,`id`),
|
|
|
|
|
ADD KEY `ui_copy_entry_scope` (`scope`,`state`,`id`),
|
|
|
|
|
ADD KEY `ui_copy_entry_manifest` (`manifest_revision`,`state`,`id`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_drafts`
|
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_draft_entry_locale` (`entry_id`,`locale_id`),
|
|
|
|
|
ADD KEY `ui_copy_draft_locale` (`locale_id`,`validation_state`,`updated_at`,`id`),
|
|
|
|
|
ADD KEY `ui_copy_draft_editor` (`updated_by`,`updated_at`,`id`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_publications`
|
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_publication_key` (`publication_key`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_publication_revision` (`locale_id`,`revision`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_publication_generation` (`locale_id`,`catalog_generation`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_publication_request` (`requested_by`,`request_idempotency_key`),
|
|
|
|
|
ADD KEY `ui_copy_publication_history` (`locale_id`,`state`,`revision`),
|
|
|
|
|
ADD KEY `ui_copy_publication_previous` (`previous_publication_id`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_revision_items`
|
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_revision_item_entry` (`publication_id`,`entry_id`),
|
|
|
|
|
ADD UNIQUE KEY `ui_copy_revision_item_key` (`publication_id`,`copy_key`),
|
|
|
|
|
ADD KEY `ui_copy_revision_entry_history` (`entry_id`,`publication_id`);
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `coupon`
|
|
|
|
|
ADD PRIMARY KEY (`id`);
|
|
|
|
|
|
|
|
|
|
@ -674,6 +863,21 @@ ALTER TABLE `legal_documents`
|
|
|
|
|
ALTER TABLE `legal_document_revisions`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_locales`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_entries`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_drafts`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_publications`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `ui_copy_revision_items`
|
|
|
|
|
MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `coupon`
|
|
|
|
|
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
|
|
|
|
|
|
|
|
|
|
|