diff --git a/web/app/Command/CloudSetup.php b/web/app/Command/CloudSetup.php index e96ff663..f9d1868c 100644 --- a/web/app/Command/CloudSetup.php +++ b/web/app/Command/CloudSetup.php @@ -8,7 +8,12 @@ use App\Services\Config; /** Initializes only the clean-break PHP business and Agent log schemas. */ final class CloudSetup { - private const SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'; + private const SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'; + /** Tables installed by ss.sql before cloudInit and owned by this schema. */ + private const PREINSTALLED_MAIN_TABLES = [ + 'ui_copy_locales', 'ui_copy_entries', 'ui_copy_drafts', + 'ui_copy_publications', 'ui_copy_revision_items', + ]; private const MAIN_TABLES = [ 'cloud_regions', 'cloud_traffic_pool_groups', 'cloud_network_lines', 'cloud_resource_pools', @@ -75,6 +80,41 @@ final class CloudSetup 'engine_vm_traffic_checkpoints', 'engine_vm_traffic_totals', ]; private const REQUIRED_MAIN_COLUMNS = [ + 'ui_copy_locales' => [ + 'id', 'locale', 'display_name', 'enabled', 'source_claim', + 'created_by', 'updated_by', 'created_at', 'updated_at', + ], + 'ui_copy_entries' => [ + 'id', 'copy_key', 'scope', 'page_key', 'location', 'kind', + 'format', 'criticality', 'required', 'allow_hide', 'max_length', + 'source_text_zh', 'source_hash_zh', + 'placeholder_contract_json', 'placeholder_hash', + 'manifest_revision', 'state', 'first_seen_at', 'last_seen_at', + 'created_by', 'updated_by', 'created_at', 'updated_at', + ], + 'ui_copy_drafts' => [ + 'id', 'entry_id', 'locale_id', 'draft_text', 'draft_hash', + 'visibility', 'translated_source_hash_zh', + 'translated_placeholder_hash', 'draft_version', + 'validation_state', 'validation_errors_json', 'created_by', + 'updated_by', 'created_at', 'updated_at', + ], + 'ui_copy_publications' => [ + 'id', 'publication_key', 'locale_id', 'revision', + 'catalog_generation', + 'previous_publication_id', 'manifest_revision', + 'manifest_hash', 'catalog_hash', 'artifact_path', 'entry_count', + 'state', 'request_idempotency_key', 'request_fingerprint', + 'requested_by', 'published_by', 'prepared_at', 'published_at', + 'error_code', 'created_at', 'updated_at', + ], + 'ui_copy_revision_items' => [ + 'id', 'publication_id', 'entry_id', 'copy_key', + 'source_text_zh', 'published_text', 'visibility', + 'source_hash_zh', 'placeholder_contract_json', + 'placeholder_hash', 'published_hash', 'manifest_revision', + 'draft_version', 'created_at', + ], 'cloud_storage_backend_catalog_mutex' => [ 'id', 'updated_at', ], @@ -569,6 +609,22 @@ final class CloudSetup ], ]; private const REQUIRED_CHECKS = [ + 'ui_copy_locales' => [ + 'chk_ui_copy_locale_shape', + ], + 'ui_copy_entries' => [ + 'chk_ui_copy_entry_shape', + ], + 'ui_copy_drafts' => [ + 'chk_ui_copy_draft_shape', + ], + 'ui_copy_publications' => [ + 'chk_ui_copy_publication_identity', + 'chk_ui_copy_publication_terminal', + ], + 'ui_copy_revision_items' => [ + 'chk_ui_copy_revision_item_shape', + ], 'cloud_storage_backend_catalog_mutex' => [ 'chk_cloud_storage_backend_catalog_mutex', ], @@ -803,6 +859,28 @@ final class CloudSetup ], ]; private const REQUIRED_INDEXES = [ + 'ui_copy_locales' => [ + 'PRIMARY', 'ui_copy_locale_name', 'ui_copy_locale_source', + 'ui_copy_locale_enabled', + ], + 'ui_copy_entries' => [ + 'PRIMARY', 'ui_copy_entry_key', 'ui_copy_entry_page', + 'ui_copy_entry_scope', 'ui_copy_entry_manifest', + ], + 'ui_copy_drafts' => [ + 'PRIMARY', 'ui_copy_draft_entry_locale', + 'ui_copy_draft_locale', 'ui_copy_draft_editor', + ], + 'ui_copy_publications' => [ + 'PRIMARY', 'ui_copy_publication_key', + 'ui_copy_publication_revision', + 'ui_copy_publication_generation', 'ui_copy_publication_request', + 'ui_copy_publication_history', 'ui_copy_publication_previous', + ], + 'ui_copy_revision_items' => [ + 'PRIMARY', 'ui_copy_revision_item_entry', + 'ui_copy_revision_item_key', 'ui_copy_revision_entry_history', + ], 'cloud_storage_backend_catalog_mutex' => [ 'PRIMARY', ], @@ -1172,6 +1250,56 @@ final class CloudSetup * non-unique. Column order is part of the ownership/fencing semantics. */ private const REQUIRED_INDEX_SHAPES = [ + 'ui_copy_locales' => [ + 'ui_copy_locale_name' => [ + 'non_unique' => 0, + 'columns' => ['locale'], + ], + 'ui_copy_locale_source' => [ + 'non_unique' => 0, + 'columns' => ['source_claim'], + ], + ], + 'ui_copy_entries' => [ + 'ui_copy_entry_key' => [ + 'non_unique' => 0, + 'columns' => ['copy_key'], + ], + ], + 'ui_copy_drafts' => [ + 'ui_copy_draft_entry_locale' => [ + 'non_unique' => 0, + 'columns' => ['entry_id', 'locale_id'], + ], + ], + 'ui_copy_publications' => [ + 'ui_copy_publication_key' => [ + 'non_unique' => 0, + 'columns' => ['publication_key'], + ], + 'ui_copy_publication_revision' => [ + 'non_unique' => 0, + 'columns' => ['locale_id', 'revision'], + ], + 'ui_copy_publication_generation' => [ + 'non_unique' => 0, + 'columns' => ['locale_id', 'catalog_generation'], + ], + 'ui_copy_publication_request' => [ + 'non_unique' => 0, + 'columns' => ['requested_by', 'request_idempotency_key'], + ], + ], + 'ui_copy_revision_items' => [ + 'ui_copy_revision_item_entry' => [ + 'non_unique' => 0, + 'columns' => ['publication_id', 'entry_id'], + ], + 'ui_copy_revision_item_key' => [ + 'non_unique' => 0, + 'columns' => ['publication_id', 'copy_key'], + ], + ], 'cloud_instance_backups' => [ 'cloud_instance_backup_create_request' => [ 'non_unique' => 0, @@ -1623,7 +1751,7 @@ final class CloudSetup $logConnection): void { $schema = $connection->getSchemaBuilder(); - foreach (self::MAIN_TABLES as $table) { + foreach (self::managedMainTables() as $table) { if (!$schema->hasTable($table)) { throw new \RuntimeException( '云数据库结构不完整,请使用全新数据库:' . $table @@ -1748,7 +1876,8 @@ final class CloudSetup private static function schemaMarker(): string { return self::SCHEMA_VERSION . ':' . hash('sha256', - self::schema('cloud.sql') . "\0" . self::schema('cloud_log.sql') + self::schema('ss.sql') . "\0" . self::schema('cloud.sql') + . "\0" . self::schema('cloud_log.sql') ); } @@ -1757,12 +1886,19 @@ final class CloudSetup $logConnection): string { return hash('sha256', json_encode([ - 'main' => self::schemaObjects($connection, self::MAIN_TABLES), + 'main' => self::schemaObjects( + $connection, self::managedMainTables() + ), 'log' => self::schemaObjects($logConnection, self::LOG_TABLES), ], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } + private static function managedMainTables(): array + { + return array_merge(self::PREINSTALLED_MAIN_TABLES, self::MAIN_TABLES); + } + private static function schemaObjects($connection, array $tables): array { $database = (string) $connection->getDatabaseName(); diff --git a/web/app/Models/UiCopyDraft.php b/web/app/Models/UiCopyDraft.php new file mode 100644 index 00000000..53d9be5e --- /dev/null +++ b/web/app/Models/UiCopyDraft.php @@ -0,0 +1,21 @@ + 'int', + 'entry_id' => 'int', + 'locale_id' => 'int', + 'draft_version' => 'int', + 'validation_errors_json' => 'array', + 'created_by' => 'int', + 'updated_by' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; +} diff --git a/web/app/Models/UiCopyEntry.php b/web/app/Models/UiCopyEntry.php new file mode 100644 index 00000000..77782084 --- /dev/null +++ b/web/app/Models/UiCopyEntry.php @@ -0,0 +1,24 @@ + 'int', + 'required' => 'bool', + 'allow_hide' => 'bool', + 'max_length' => 'int', + 'placeholder_contract_json' => 'array', + 'manifest_revision' => 'int', + 'first_seen_at' => 'int', + 'last_seen_at' => 'int', + 'created_by' => 'int', + 'updated_by' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; +} diff --git a/web/app/Models/UiCopyLocale.php b/web/app/Models/UiCopyLocale.php new file mode 100644 index 00000000..39fcc9cb --- /dev/null +++ b/web/app/Models/UiCopyLocale.php @@ -0,0 +1,19 @@ + 'int', + 'enabled' => 'bool', + 'source_claim' => 'int', + 'created_by' => 'int', + 'updated_by' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; +} diff --git a/web/app/Models/UiCopyPublication.php b/web/app/Models/UiCopyPublication.php new file mode 100644 index 00000000..390b967f --- /dev/null +++ b/web/app/Models/UiCopyPublication.php @@ -0,0 +1,24 @@ + 'int', + 'locale_id' => 'int', + 'revision' => 'int', + 'previous_publication_id' => 'int', + 'manifest_revision' => 'int', + 'entry_count' => 'int', + 'requested_by' => 'int', + 'published_by' => 'int', + 'prepared_at' => 'int', + 'published_at' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; +} diff --git a/web/app/Models/UiCopyRevisionItem.php b/web/app/Models/UiCopyRevisionItem.php new file mode 100644 index 00000000..0353db2b --- /dev/null +++ b/web/app/Models/UiCopyRevisionItem.php @@ -0,0 +1,19 @@ + 'int', + 'publication_id' => 'int', + 'entry_id' => 'int', + 'placeholder_contract_json' => 'array', + 'manifest_revision' => 'int', + 'draft_version' => 'int', + 'created_at' => 'int', + ]; +} diff --git a/web/sql/ss.sql b/web/sql/ss.sql index 7a8c40d5..50dd5552 100644 --- a/web/sql/ss.sql +++ b/web/sql/ss.sql @@ -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; diff --git a/web/tests/CloudBackupPublicationPreparationSchemaContractTest.php b/web/tests/CloudBackupPublicationPreparationSchemaContractTest.php index 7200132a..7db5493f 100644 --- a/web/tests/CloudBackupPublicationPreparationSchemaContractTest.php +++ b/web/tests/CloudBackupPublicationPreparationSchemaContractTest.php @@ -52,7 +52,7 @@ foreach ([ 'CloudSetup omits backup preparation contract: ' . $required); } $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'columns' => [\n 'create_request_actor_id',\n 'create_request_idempotency_key',") && str_contains($setup, "'non_unique' => 0"), diff --git a/web/tests/CloudFreshSchemaContractTest.php b/web/tests/CloudFreshSchemaContractTest.php index ee56691b..a005fc7c 100644 --- a/web/tests/CloudFreshSchemaContractTest.php +++ b/web/tests/CloudFreshSchemaContractTest.php @@ -22,7 +22,7 @@ $assert(stripos($schema, 'compatibility import') === false $assert(!preg_match('/\bengine_[A-Za-z0-9_]*\b/', $schema), 'cloud.sql retained an engine-prefixed identifier.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && !str_contains($setup, "SCHEMA_VERSION = 'go-v1'"), 'Outbound Agent schema must reject the incompatible earlier Go database.'); $assert(str_contains($schema, diff --git a/web/tests/CloudMaintenanceNoticeSchemaContractTest.php b/web/tests/CloudMaintenanceNoticeSchemaContractTest.php index 8d29554d..9eba22e4 100644 --- a/web/tests/CloudMaintenanceNoticeSchemaContractTest.php +++ b/web/tests/CloudMaintenanceNoticeSchemaContractTest.php @@ -56,7 +56,7 @@ foreach ([ } $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"), + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"), 'CloudSetup schema version was not advanced for maintenance notices.'); echo "Maintenance notice schema contracts passed.\n"; diff --git a/web/tests/CloudPublicIpPoolReplacementSchemaContractTest.php b/web/tests/CloudPublicIpPoolReplacementSchemaContractTest.php index b74692f2..6f2bbd52 100644 --- a/web/tests/CloudPublicIpPoolReplacementSchemaContractTest.php +++ b/web/tests/CloudPublicIpPoolReplacementSchemaContractTest.php @@ -53,7 +53,7 @@ $assert(is_string($schema) 'Public-pool replacement lacks durable batch, child, or claim schema.'); $assert(is_string($setup) && str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'cloud_public_ip_pool_replacement_batches'") && str_contains($setup, diff --git a/web/tests/CloudPublicNetworkTransitionSchemaContractTest.php b/web/tests/CloudPublicNetworkTransitionSchemaContractTest.php index cfc4eae7..531fc76a 100644 --- a/web/tests/CloudPublicNetworkTransitionSchemaContractTest.php +++ b/web/tests/CloudPublicNetworkTransitionSchemaContractTest.php @@ -170,7 +170,7 @@ $assert(str_contains($setup, 'CloudSetup does not verify index uniqueness and ordered columns.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'cloud_public_network_transitions'") && str_contains($setup, "'cloud_public_network_transition_ips'") && str_contains($setup, "'reservation_ip_claim_id'") diff --git a/web/tests/CloudRescueCatalogSchemaContractTest.php b/web/tests/CloudRescueCatalogSchemaContractTest.php index 1f9c05f5..944c9133 100644 --- a/web/tests/CloudRescueCatalogSchemaContractTest.php +++ b/web/tests/CloudRescueCatalogSchemaContractTest.php @@ -57,7 +57,7 @@ $assert($replica !== '' && str_contains($replica, 'cleanup_resolved_at BIGINT UNSIGNED'), 'Rescue replica cannot prove exact identity or retain cleanup debt.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'cloud_rescue_artifact_delete_due'") && str_contains($setup, "'cloud_rescue_replica_cleanup'"), 'CloudSetup version or rescue catalog indexes are incomplete.'); diff --git a/web/tests/CloudRestoreMigrationLedgerContractTest.php b/web/tests/CloudRestoreMigrationLedgerContractTest.php index ba29d5bc..e048506c 100644 --- a/web/tests/CloudRestoreMigrationLedgerContractTest.php +++ b/web/tests/CloudRestoreMigrationLedgerContractTest.php @@ -218,7 +218,7 @@ foreach ([ 'CloudSetup omits restore/migration ledger contract: ' . $required); } $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($attemptModel, "protected \$table = 'cloud_backup_restore_attempts';") && str_contains($attemptModel, "'active_attempt' => 'int'") diff --git a/web/tests/CloudServiceCompensationSchemaContractTest.php b/web/tests/CloudServiceCompensationSchemaContractTest.php index 52ec80ec..765b9058 100644 --- a/web/tests/CloudServiceCompensationSchemaContractTest.php +++ b/web/tests/CloudServiceCompensationSchemaContractTest.php @@ -105,7 +105,7 @@ $assert(str_contains($setup, 'CloudSetup lost the open-compensation fence index contract.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"), + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"), 'CloudSetup schema version was not advanced for service compensation.'); $appliedShape = preg_match( diff --git a/web/tests/CloudStoragePublicationSchemaContractTest.php b/web/tests/CloudStoragePublicationSchemaContractTest.php index d7b7c186..38123fd3 100644 --- a/web/tests/CloudStoragePublicationSchemaContractTest.php +++ b/web/tests/CloudStoragePublicationSchemaContractTest.php @@ -137,7 +137,7 @@ $assert(is_string($publicationModel) && str_contains($artifactModel, "'maximum_size_bytes' => 'int'"), 'Storage publication/artifact model contracts are incomplete.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"), + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"), 'CloudSetup schema version was not advanced for durable publications.'); echo "Storage publication schema contracts passed.\n"; diff --git a/web/tests/CloudTemplateImportIntentContractTest.php b/web/tests/CloudTemplateImportIntentContractTest.php index 84ddb230..885beb3a 100644 --- a/web/tests/CloudTemplateImportIntentContractTest.php +++ b/web/tests/CloudTemplateImportIntentContractTest.php @@ -63,7 +63,7 @@ $assert(str_contains($schema, && str_contains($schema, 'CONSTRAINT chk_cloud_template_import_completion CHECK (') && str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'"), + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'"), 'Template imports are missing durable identity or terminal-state constraints.'); $assert(str_contains($routes, "'/admin/cloud-template-imports'") && str_contains($routes, "'/admin/cloud-template-imports/{id}'") diff --git a/web/tests/CloudTrafficPoolSchemaContractTest.php b/web/tests/CloudTrafficPoolSchemaContractTest.php index a19cd55d..8e463eec 100644 --- a/web/tests/CloudTrafficPoolSchemaContractTest.php +++ b/web/tests/CloudTrafficPoolSchemaContractTest.php @@ -71,7 +71,7 @@ $assert(str_contains($schema, 'Service-period traffic-pool identity is not frozen or indexed.'); $assert(str_contains($setup, - "SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'chk_cloud_traffic_entitlement_balance'") && str_contains($setup, "'cloud_traffic_ledger_sequence'"), 'CloudSetup schema version or named-object validation is incomplete.'); diff --git a/web/tests/CloudVpcSchemaContractTest.php b/web/tests/CloudVpcSchemaContractTest.php index 735321af..114f161b 100644 --- a/web/tests/CloudVpcSchemaContractTest.php +++ b/web/tests/CloudVpcSchemaContractTest.php @@ -101,7 +101,7 @@ $assert(str_contains($jobs, 'vpc_id BIGINT UNSIGNED DEFAULT NULL') 'Cloud jobs cannot be correlated to VPC or VPC-port work.'); $assert(str_contains($setup, - "private const SCHEMA_VERSION = 'go-agent-wss-v38-backup-publication-preparation'") + "private const SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") && str_contains($setup, "'name' => 'cloud_vpc_enabled'") && str_contains($setup, "'value' => 'false'") && str_contains($setup, diff --git a/web/tests/UiCopyCatalogSchemaContractTest.php b/web/tests/UiCopyCatalogSchemaContractTest.php new file mode 100644 index 00000000..025882c7 --- /dev/null +++ b/web/tests/UiCopyCatalogSchemaContractTest.php @@ -0,0 +1,114 @@ + 'ui_copy_locales', + 'UiCopyEntry' => 'ui_copy_entries', + 'UiCopyDraft' => 'ui_copy_drafts', + 'UiCopyPublication' => 'ui_copy_publications', + 'UiCopyRevisionItem' => 'ui_copy_revision_items', +]; +foreach ($models as $class => $modelTable) { + $model = file_get_contents($root . '/app/Models/' . $class . '.php'); + $assert(is_string($model) + && str_contains($model, "protected \$table = '" . $modelTable . "'"), + 'UI copy model contract is missing: ' . $class); +} + +$assert(str_contains($setup, + "SCHEMA_VERSION = 'go-agent-wss-v39-ui-copy-catalog'") + && str_contains($setup, + "self::schema('ss.sql') . \"\\0\" . self::schema('cloud.sql')") + && str_contains($setup, + 'self::managedMainTables()'), + 'Clean-break marker/fingerprint does not cover the UI copy schema.'); + +echo "UI copy catalog schema contracts passed.\n";