You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2636 lines
114 KiB
PHP
2636 lines
114 KiB
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use App\Models\User;
|
|
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-v51-compact-telemetry-storage';
|
|
/** 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',
|
|
'cloud_hosts', 'cloud_host_agents',
|
|
'cloud_host_storage_configurations', 'cloud_templates',
|
|
'cloud_storage_backend_catalog_mutex',
|
|
'cloud_storage_backends', 'cloud_storage_artifacts',
|
|
'cloud_storage_replicas', 'cloud_storage_operations',
|
|
'cloud_template_import_intents', 'cloud_template_import_parts',
|
|
'cloud_template_artifacts', 'cloud_template_replicas',
|
|
'cloud_user_isos',
|
|
'cloud_user_iso_replicas', 'cloud_rescue_templates',
|
|
'cloud_rescue_template_artifacts', 'cloud_rescue_template_replicas',
|
|
'cloud_host_resource_pool_memberships',
|
|
'cloud_host_network_attachments',
|
|
'cloud_public_ip_pool_catalog_mutex', 'cloud_public_ip_pools',
|
|
'cloud_public_ip_pool_replacement_batches',
|
|
'cloud_public_ip_pool_replacement_batch_items',
|
|
'cloud_host_vpc_transports', 'cloud_vpc_cidr_pools',
|
|
'cloud_host_capacity_policies', 'cloud_public_ips', 'cloud_offers',
|
|
'cloud_instances', 'cloud_vpcs', 'cloud_vpc_ports',
|
|
'cloud_vpc_host_states', 'cloud_vpc_membership_batches',
|
|
'cloud_vpc_membership_batch_items', 'cloud_instance_firewalls',
|
|
'cloud_instance_firewall_versions', 'cloud_instance_firewall_rules',
|
|
'cloud_platform_test_policy_state',
|
|
'cloud_platform_test_policy_rules', 'cloud_instance_snapshots',
|
|
'cloud_backup_subscriptions', 'cloud_backup_period_entitlements',
|
|
'cloud_instance_backups', 'cloud_storage_publications',
|
|
'cloud_deployment_snapshots',
|
|
'cloud_backup_restores', 'cloud_backup_restore_attempts',
|
|
'cloud_backup_recoveries', 'cloud_instance_migrations',
|
|
'cloud_instance_migration_source_debts',
|
|
'cloud_peer_migration_artifacts',
|
|
'cloud_instance_runtime', 'cloud_orders', 'cloud_order_items',
|
|
'cloud_resource_reservations', 'cloud_resource_reservation_ips',
|
|
'cloud_public_network_transitions',
|
|
'cloud_public_network_transition_ips',
|
|
'cloud_service_periods',
|
|
'cloud_traffic_pools', 'cloud_traffic_entitlements',
|
|
'cloud_traffic_ledger_events',
|
|
'cloud_traffic_usage_settlement_buckets',
|
|
'cloud_traffic_instance_cursors',
|
|
'cloud_traffic_scan_failures',
|
|
'cloud_instance_network_restrictions',
|
|
'cloud_instance_network_policy_states',
|
|
'cloud_renewals', 'cloud_invoices', 'cloud_invoice_items',
|
|
'cloud_invoice_payments',
|
|
'cloud_mail_outbox', 'cloud_maintenance_notices',
|
|
'cloud_maintenance_notice_instances',
|
|
'cloud_maintenance_notice_recipients',
|
|
'cloud_service_compensations',
|
|
'cloud_service_compensation_items',
|
|
'cloud_service_compensation_recipients',
|
|
'cloud_abuse_policy_revisions', 'cloud_abuse_policy_rules',
|
|
'cloud_abuse_instance_states', 'cloud_abuse_findings',
|
|
'cloud_abuse_alert_events', 'cloud_abuse_alert_event_items',
|
|
'cloud_abuse_alert_deliveries',
|
|
'administrator_telegram_delivery_gate',
|
|
'cloud_abuse_projection_receipts',
|
|
'cloud_jobs', 'cloud_agent_completion_events',
|
|
'cloud_ssh_keys',
|
|
'cloud_sessions', 'cloud_console_tickets',
|
|
];
|
|
private const LOG_TABLES = [
|
|
'cloud_vm_metric_samples', 'cloud_vm_metric_rollups',
|
|
'cloud_vm_traffic_checkpoints',
|
|
'cloud_vm_traffic_totals', 'cloud_vm_daily_traffic_cursors',
|
|
'cloud_vm_daily_traffic',
|
|
'cloud_vm_network_observation_samples',
|
|
'cloud_vm_network_observation_rollups',
|
|
'cloud_vm_network_projection_outbox',
|
|
'cloud_vm_network_monitor_cursors',
|
|
'cloud_vm_network_baselines',
|
|
];
|
|
/** Refusal-only denylist: never read, import, rename or migrate these rows. */
|
|
private const RETIRED_LOG_TABLES = [
|
|
'engine_vm_metric_samples',
|
|
'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',
|
|
],
|
|
'cloud_storage_backends' => [
|
|
'id', 'backend_key', 'identity_sha256', 'name', 'driver',
|
|
'endpoint', 'region', 'bucket', 'prefix', 'path_style',
|
|
'failure_domain', 'sealed_credentials', 'config_revision',
|
|
'tested_revision', 'admin_state', 'health_state',
|
|
'write_priority', 'consecutive_failures',
|
|
'consecutive_successes', 'last_error_code', 'last_tested_at',
|
|
'last_healthy_at', 'next_probe_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_storage_artifacts' => [
|
|
'id', 'artifact_key', 'kind', 'maximum_size_bytes',
|
|
'size_bytes', 'sha256',
|
|
'durability_policy', 'desired_copies', 'required_copies',
|
|
'state', 'last_operation_id', 'verified_at', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_storage_replicas' => [
|
|
'id', 'replica_key', 'artifact_id', 'backend_id', 'role',
|
|
'object_key', 'object_version_id', 'object_etag', 'size_bytes',
|
|
'sha256', 'state', 'publish_operation_id',
|
|
'delete_operation_id', 'delete_generation',
|
|
'delete_cycle_attempts', 'delete_presence_confirmations',
|
|
'delete_last_checked_at', 'delete_next_check_at',
|
|
'delete_attention_at', 'lease_token', 'lease_until',
|
|
'error_code', 'verified_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_storage_operations' => [
|
|
'id', 'operation_id', 'request_idempotency_key',
|
|
'request_fingerprint', 'artifact_id', 'replica_id',
|
|
'source_backend_id', 'target_backend_id', 'kind', 'phase',
|
|
'outcome', 'effect_resolution', 'effect_may_have_applied',
|
|
'safe_to_resubmit', 'attempts', 'lease_token', 'lease_until',
|
|
'available_at', 'next_check_at', 'error_code', 'result_json',
|
|
'terminal_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_ip_pool_catalog_mutex' => [
|
|
'id', 'updated_at',
|
|
],
|
|
'cloud_host_agents' => [
|
|
'host_id', 'revision', 'tested_revision',
|
|
'network_selectors_json', 'public_network_capabilities_json',
|
|
'portable_restore_contract_json',
|
|
'portable_restore_contract_sha256',
|
|
'last_tested_at',
|
|
],
|
|
'cloud_host_network_attachments' => [
|
|
'id', 'attachment_key', 'host_id', 'line_id', 'name',
|
|
'network_mode', 'network_selector', 'state', 'priority',
|
|
'config_revision', 'verified_agent_revision',
|
|
'verification_state', 'last_verified_at',
|
|
'verification_error_code', 'desired_revision',
|
|
'observed_revision', 'sync_state', 'last_error_code',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_host_resource_pool_memberships' => [
|
|
'id', 'host_id', 'resource_pool_id', 'scheduler_state',
|
|
'priority', 'weight', 'revision', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_ip_pools' => [
|
|
'id', 'pool_key', 'host_id', 'network_attachment_id',
|
|
'address_family', 'name', 'cidr', 'gateway', 'gateway_on_link',
|
|
'guest_prefix_length', 'dns_servers_json', 'reserved_ips_json',
|
|
'allocation_start', 'allocation_end', 'allocation_cursor',
|
|
'max_allocations', 'state', 'priority', 'desired_revision',
|
|
'observed_revision', 'sync_state', 'last_error_code',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_ips' => [
|
|
'id', 'host_id', 'public_ip_pool_id', 'address_family',
|
|
'address', 'address_binary', 'prefix_length', 'state',
|
|
'reservation_id', 'reservation_ip_claim_id', 'instance_id',
|
|
'operation_id',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_traffic_pool_groups' => [
|
|
'id', 'code', 'name', 'mode', 'revision', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_network_lines' => [
|
|
'id', 'region_id', 'traffic_pool_group_id', 'code', 'name',
|
|
'is_default', 'status', 'sort', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_template_import_intents' => [
|
|
'id', 'user_id', 'request_idempotency_key',
|
|
'request_fingerprint', 'source_kind', 'name', 'os_family',
|
|
'os_version', 'source_filename', 'source_size_bytes',
|
|
'source_last_modified', 'source_sha256', 'sealed_source',
|
|
'template_id', 'catalog_key', 'version_label',
|
|
'generation_token', 'storage_revision',
|
|
'object_key', 'multipart_upload_id',
|
|
'multipart_part_size_bytes', 'multipart_part_count',
|
|
'object_version_id', 'object_etag', 'state', 'active_job_id',
|
|
'error_code', 'expires_at', 'completed_at', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_template_import_parts' => [
|
|
'intent_id', 'part_number', 'size_bytes', 'etag',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_template_artifacts' => [
|
|
'template_id', 'storage_artifact_id', 'storage_revision',
|
|
'object_key', 'object_version_id', 'object_etag', 'size_bytes',
|
|
'sha256', 'state', 'error_code', 'delete_operation_id',
|
|
'delete_generation', 'delete_cycle_attempts',
|
|
'delete_presence_confirmations', 'delete_last_checked_at',
|
|
'delete_next_check_at', 'delete_attention_at', 'verified_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_template_replicas' => [
|
|
'host_id', 'template_id', 'revision', 'generation_token',
|
|
'state', 'image_bytes', 'sha256', 'operation_id', 'job_id',
|
|
'error_code', 'observed_state', 'observed_revision',
|
|
'observed_generation_token', 'observed_image_bytes',
|
|
'observed_sha256', 'last_verified_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_rescue_templates' => [
|
|
'id', 'name', 'size_bytes', 'sha256', 'revision',
|
|
'generation_token', 'state', 'active_job_id',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_rescue_template_artifacts' => [
|
|
'template_id', 'storage_artifact_id', 'storage_revision',
|
|
'object_key', 'object_version_id', 'object_etag', 'size_bytes',
|
|
'sha256', 'state', 'error_code', 'delete_operation_id',
|
|
'delete_generation', 'delete_cycle_attempts',
|
|
'delete_presence_confirmations', 'delete_last_checked_at',
|
|
'delete_next_check_at', 'delete_attention_at', 'verified_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_rescue_template_replicas' => [
|
|
'host_id', 'template_id', 'revision', 'generation_token',
|
|
'state', 'size_bytes', 'sha256', 'operation_id', 'job_id',
|
|
'error_code', 'observed_state', 'observed_revision',
|
|
'observed_generation_token', 'observed_size_bytes',
|
|
'observed_sha256', 'last_verified_at', 'cleanup_resolved_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_offers' => [
|
|
'price', 'quarterly_price', 'annual_price',
|
|
'backup_price', 'backup_quarterly_price',
|
|
'backup_annual_price',
|
|
],
|
|
'cloud_jobs' => [
|
|
'id', 'operation_id', 'request_idempotency_key',
|
|
'request_fingerprint', 'parent_job_id', 'user_id', 'host_id',
|
|
'backup_id', 'backup_restore_id', 'backup_recovery_id',
|
|
'public_network_transition_id',
|
|
'vpc_id', 'vpc_port_id', 'vpc_batch_id',
|
|
'kind', 'execution_mode', 'phase', 'outcome', 'status',
|
|
'attempts', 'dispatch_attempts', 'dispatch_deadline_at',
|
|
'dispatch_started_at', 'agent_accepted_at',
|
|
'receipt_deadline_at', 'terminal_at',
|
|
'effect_may_have_applied', 'safe_to_resubmit',
|
|
'effect_resolution', 'finalization_incident',
|
|
'finalization_error_code', 'completion_event_id', 'read_at',
|
|
'lease_token', 'lease_until', 'available_at', 'error_code',
|
|
'result_json', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_host_vpc_transports' => [
|
|
'host_id', 'transport_address', 'transport_prefix_length',
|
|
'transport_interface', 'transport_mode', 'mtu',
|
|
'desired_revision', 'observed_revision', 'sync_state',
|
|
'last_operation_id', 'last_error_code', 'last_verified_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpc_cidr_pools' => [
|
|
'id', 'pool_key', 'region_id', 'name', 'cidr',
|
|
'prefix_length', 'allocation_prefix', 'state',
|
|
'revision', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpcs' => [
|
|
'id', 'vpc_key', 'user_id', 'region_id', 'cidr_pool_id',
|
|
'name', 'cidr', 'prefix_length', 'gateway', 'active_claim', 'state',
|
|
'desired_revision', 'deleted_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpc_ports' => [
|
|
'id', 'port_key', 'vpc_id', 'instance_id',
|
|
'migration_host_id', 'user_id',
|
|
'private_ip', 'mac_address', 'active_claim', 'state',
|
|
'desired_revision', 'applied_revision', 'last_operation_id',
|
|
'last_error_code', 'attached_at', 'released_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpc_host_states' => [
|
|
'id', 'vpc_id', 'host_id', 'desired_revision',
|
|
'applied_revision', 'desired_digest', 'applied_digest',
|
|
'sync_state', 'last_operation_id', 'last_error_code',
|
|
'last_success_at', 'last_failure_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpc_membership_batches' => [
|
|
'id', 'batch_key', 'vpc_id', 'user_id', 'parent_job_id',
|
|
'kind', 'state', 'desired_revision', 'active_claim',
|
|
'last_error_code', 'terminal_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vpc_membership_batch_items' => [
|
|
'id', 'batch_id', 'user_id', 'instance_id', 'vpc_port_id',
|
|
'host_id', 'child_job_id', 'state', 'last_error_code',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batches' => [
|
|
'id', 'batch_key', 'host_id', 'source_public_ip_pool_id',
|
|
'target_public_ip_pool_id', 'source_initial_state',
|
|
'parent_job_id',
|
|
'requested_by_user_id', 'state', 'active_claim',
|
|
'last_error_code', 'terminal_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batch_items' => [
|
|
'id', 'batch_id', 'instance_id', 'address_family',
|
|
'source_reservation_id',
|
|
'source_public_ip_id', 'target_public_ip_id',
|
|
'source_network_attachment_id',
|
|
'target_network_attachment_id', 'child_job_id', 'state',
|
|
'last_error_code', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_agent_completion_events' => [
|
|
'event_id', 'host_id', 'operation_id', 'payload_sha256',
|
|
'outcome', 'effect_may_have_applied', 'safe_to_resubmit',
|
|
'error_code', 'result_json', 'disposition', 'received_at',
|
|
'applied_at',
|
|
],
|
|
'cloud_backup_subscriptions' => [
|
|
'id', 'instance_id', 'user_id', 'offer_id', 'enabled',
|
|
'renew_next_period', 'frequency', 'weekday', 'retention_count',
|
|
'timezone', 'price', 'currency', 'price_version',
|
|
'state_revision', 'next_run_at', 'deferred_until',
|
|
'defer_reason', 'deferred_at', 'defer_count',
|
|
'last_scheduled_at', 'last_backup_id', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_backup_period_entitlements' => [
|
|
'id', 'subscription_id', 'instance_id', 'service_period_id',
|
|
'user_id', 'offer_id', 'invoice_id', 'starts_at', 'ends_at',
|
|
'amount', 'full_period_price', 'currency', 'price_version',
|
|
'source', 'paid_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_instance_backups' => [
|
|
'id', 'backup_key', 'create_request_actor_id',
|
|
'create_request_idempotency_key',
|
|
'create_request_fingerprint', 'storage_artifact_id',
|
|
'source_instance_id', 'source_host_id',
|
|
'user_id', 'source_uuid', 'name', 'purpose', 'source',
|
|
'subscription_id', 'scheduled_for', 'schedule_attempt',
|
|
'state', 'consistency',
|
|
'object_key', 'object_size_bytes', 'virtual_size_bytes',
|
|
'sha256', 'object_etag', 'object_version_id', 'spec_json',
|
|
'source_portable_restore_contract_json',
|
|
'source_portable_restore_contract_sha256',
|
|
'sealed_credential', 'storage_revision', 'active_job_id',
|
|
'last_operation_id', 'delete_operation_id', 'delete_generation',
|
|
'delete_cycle_attempts', 'delete_presence_confirmations',
|
|
'delete_requested_at', 'delete_last_checked_at',
|
|
'delete_next_check_at', 'delete_attention_at', 'error_code',
|
|
'ready_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_storage_publications' => [
|
|
'id', 'publication_key', 'artifact_id', 'backup_id',
|
|
'template_import_intent_id', 'rescue_template_id', 'state',
|
|
'attempts', 'available_at', 'lease_token', 'lease_until',
|
|
'last_error_code', 'coverage_ready_at', 'finalized_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_deployment_snapshots' => [
|
|
'id', 'snapshot_key', 'user_id', 'backup_id',
|
|
'source_instance_id', 'name', 'state', 'idempotency_key',
|
|
'request_hash', 'error_code', 'ready_at', 'deleted_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_orders' => [
|
|
'deployment_snapshot_id',
|
|
],
|
|
'cloud_backup_restores' => [
|
|
'id', 'restore_key', 'backup_id', 'requested_by_user_id',
|
|
'request_idempotency_key', 'request_fingerprint',
|
|
'selected_plan_json', 'selected_plan_sha256', 'target_host_id',
|
|
'target_instance_id', 'reservation_id', 'job_id', 'operation_id',
|
|
'new_uuid', 'new_name', 'state', 'error_code', 'ready_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_backup_restore_attempts' => [
|
|
'id', 'attempt_key', 'backup_restore_id', 'generation',
|
|
'operation_id', 'job_id', 'reservation_id', 'target_host_id',
|
|
'target_uuid', 'target_name', 'target_plan_json',
|
|
'target_plan_sha256', 'target_network_attachment_id',
|
|
'target_identity_json', 'target_identity_sha256',
|
|
'target_claim_set_sha256', 'target_public_network_json',
|
|
'target_public_network_sha256', 'state', 'effect_resolution',
|
|
'evidence_resolution', 'evidence_json', 'evidence_sha256',
|
|
'evidence_recorded_at', 'active_attempt', 'last_error_code',
|
|
'finalization_error_code', 'effect_resolved_at',
|
|
'terminal_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_backup_recoveries' => [
|
|
'id', 'recovery_key', 'backup_id', 'instance_id', 'job_id',
|
|
'operation_id', 'state', 'error_code', 'completed_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_order_items' => [
|
|
'id', 'order_id', 'code', 'label', 'amount', 'currency',
|
|
'snapshot_json', 'created_at',
|
|
],
|
|
'cloud_invoice_items' => [
|
|
'id', 'invoice_id', 'order_item_id', 'code', 'label', 'amount',
|
|
'currency', 'snapshot_json', 'created_at',
|
|
],
|
|
'cloud_maintenance_notices' => [
|
|
'id', 'notice_key', 'requested_by_user_id',
|
|
'request_idempotency_key', 'request_fingerprint', 'scope_type',
|
|
'scope_id', 'scope_snapshot_json', 'subject', 'message_text',
|
|
'impact', 'maintenance_starts_at', 'maintenance_ends_at',
|
|
'scheduled_at', 'audience_digest', 'instance_count',
|
|
'recipient_count', 'skipped_count', 'status', 'last_error_code',
|
|
'terminal_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_maintenance_notice_instances' => [
|
|
'id', 'notice_id', 'instance_id', 'user_id', 'host_id',
|
|
'public_ip_pool_id', 'instance_name', 'ipv4', 'ipv6',
|
|
'evidence_json', 'created_at',
|
|
],
|
|
'cloud_maintenance_notice_recipients' => [
|
|
'id', 'notice_id', 'user_id', 'email_snapshot', 'status',
|
|
'attempts', 'available_at', 'lease_token', 'lease_until',
|
|
'sent_at', 'last_error_code', 'last_error', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_service_compensations' => [
|
|
'id', 'compensation_key', 'incident_key',
|
|
'requested_by_user_id', 'request_idempotency_key',
|
|
'request_fingerprint', 'scope_type', 'scope_id',
|
|
'scope_snapshot_json', 'reason_text', 'incident_starts_at',
|
|
'incident_ends_at', 'compensation_seconds', 'notify_users',
|
|
'audience_digest', 'instance_count', 'recipient_count',
|
|
'applied_count', 'deferred_count', 'rejected_count',
|
|
'attention_count', 'state', 'last_error_code', 'terminal_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_service_compensation_items' => [
|
|
'id', 'item_key', 'batch_id', 'incident_key', 'instance_id',
|
|
'user_id', 'host_id', 'instance_name', 'requested_seconds',
|
|
'service_period_id', 'traffic_entitlement_id',
|
|
'backup_entitlement_id', 'source_invoice_id',
|
|
'replacement_invoice_id', 'audit_job_id', 'before_expires_at',
|
|
'after_expires_at', 'before_period_ends_at',
|
|
'after_period_ends_at', 'before_traffic_ends_at',
|
|
'after_traffic_ends_at', 'before_backup_ends_at',
|
|
'after_backup_ends_at', 'before_snapshot_json',
|
|
'after_snapshot_json', 'state', 'attempts', 'available_at',
|
|
'lease_token', 'lease_until', 'applied_at', 'terminal_at',
|
|
'last_error_code', 'last_error', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_service_compensation_recipients' => [
|
|
'id', 'batch_id', 'user_id', 'email_snapshot',
|
|
'instance_count', 'payload_json', 'payload_sha256', 'status',
|
|
'attempts', 'available_at', 'lease_token', 'lease_until',
|
|
'sent_at', 'last_error_code', 'last_error', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_instance_migrations' => [
|
|
'id', 'migration_key', 'instance_id', 'vpc_port_id', 'restore_id',
|
|
'source_host_id', 'source_uuid', 'source_reservation_id',
|
|
'target_host_id', 'target_uuid', 'target_reservation_id',
|
|
'source_prepare_job_id', 'target_receive_job_id',
|
|
'firewall_job_id',
|
|
'activate_job_id', 'rollback_job_id', 'cleanup_job_id',
|
|
'cleanup_mode', 'state', 'recovery_action', 'retry_generation',
|
|
'source_endpoint', 'peer_trust_id', 'manifest_digest',
|
|
'source_was_running', 'source_autostart_enabled',
|
|
'source_service_status', 'source_network_status', 'error_code',
|
|
'cutover_at', 'completed_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_instance_migration_source_debts' => [
|
|
'id', 'debt_key', 'migration_id', 'source_reservation_id',
|
|
'source_host_id', 'source_uuid',
|
|
'source_network_attachment_id', 'source_identity_json',
|
|
'source_identity_sha256', 'source_claim_set_sha256',
|
|
'source_public_network_json', 'source_public_network_sha256',
|
|
'cleanup_operation_id', 'cleanup_job_id', 'state',
|
|
'active_debt', 'last_error_code', 'resolved_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_peer_migration_artifacts' => [
|
|
'id', 'migration_id', 'artifact_id', 'role',
|
|
'source_snapshot_id', 'snapshot_key', 'name', 'consistency',
|
|
'object_size_bytes',
|
|
'virtual_size_bytes', 'sha256', 'state', 'snapshot_created_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_resource_reservations' => [
|
|
'id', 'reservation_key', 'operation_id', 'order_id',
|
|
'backup_restore_id', 'backup_restore_attempt_key',
|
|
'migration_source_debt_id', 'offer_id', 'resource_pool_id',
|
|
'host_id',
|
|
'user_id', 'instance_id', 'network_attachment_id',
|
|
'public_ip_pool_id', 'public_ip_id', 'cpu_cores', 'memory_mib',
|
|
'disk_gib', 'state', 'expires_at', 'released_at',
|
|
'release_reason', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_resource_reservation_ips' => [
|
|
'id', 'reservation_id', 'address_family', 'claim_generation',
|
|
'active_claim',
|
|
'network_attachment_id', 'public_ip_pool_id', 'public_ip_id',
|
|
'operation_id', 'state', 'released_at', 'release_reason',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_network_transitions' => [
|
|
'id', 'transition_key', 'operation_id', 'kind', 'instance_id',
|
|
'host_id', 'reservation_id', 'invoice_id',
|
|
'pool_replacement_batch_item_id', 'requested_by_user_id',
|
|
'source_network_attachment_id', 'target_network_attachment_id',
|
|
'source_claim_set_sha256', 'target_claim_set_sha256',
|
|
'source_public_network_json', 'source_public_network_sha256',
|
|
'target_public_network_json', 'target_public_network_sha256',
|
|
'state', 'effect_resolution', 'active_transition',
|
|
'last_error_code', 'effect_resolved_at', 'terminal_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_public_network_transition_ips' => [
|
|
'id', 'transition_id', 'address_family', 'source_claim_id',
|
|
'target_claim_id', 'changed', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_service_periods' => [
|
|
'id', 'instance_id', 'user_id', 'plan_id', 'order_id',
|
|
'renewal_id', 'traffic_pool_group_id', 'traffic_quota_mode',
|
|
'starts_at', 'ends_at', 'traffic_quota_bytes',
|
|
'download_base_bytes', 'upload_base_bytes',
|
|
'download_used_bytes', 'upload_used_bytes', 'status',
|
|
'activated_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_traffic_pools' => [
|
|
'id', 'user_id', 'traffic_pool_group_id', 'state',
|
|
'available_bytes', 'overage_bytes', 'version', 'last_sequence',
|
|
'last_event_id', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_traffic_entitlements' => [
|
|
'id', 'pool_id', 'user_id', 'instance_id',
|
|
'service_period_id', 'starts_at', 'ends_at', 'quota_mode',
|
|
'granted_bytes', 'consumed_bytes', 'forfeited_bytes', 'state',
|
|
'activated_at', 'closed_at', 'version', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_traffic_ledger_events' => [
|
|
'id', 'pool_id', 'user_id', 'pool_sequence', 'event_key',
|
|
'event_type', 'source_type', 'source_id', 'source_revision',
|
|
'payload_hash', 'instance_id', 'service_period_id',
|
|
'entitlement_id', 'amount_bytes', 'effective_at',
|
|
'observed_at', 'payload_json', 'created_at',
|
|
],
|
|
'cloud_traffic_usage_settlement_buckets' => [
|
|
'id', 'pool_id', 'user_id', 'instance_id', 'service_period_id',
|
|
'entitlement_id', 'allocation_kind', 'allocation_target_id',
|
|
'bucket_start', 'bucket_revision', 'amount_bytes',
|
|
'download_bytes', 'upload_bytes',
|
|
'sample_count', 'first_observed_at', 'last_observed_at', 'state',
|
|
'sealed_event_id', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_traffic_instance_cursors' => [
|
|
'instance_id', 'user_id', 'pool_id',
|
|
'accounted_download_bytes', 'accounted_upload_bytes',
|
|
'last_observed_at', 'last_event_id', 'state',
|
|
'attention_code', 'version', 'updated_at',
|
|
],
|
|
'cloud_traffic_scan_failures' => [
|
|
'id', 'scan_kind', 'subject_id', 'attempt_count',
|
|
'last_error_code', 'retry_at', 'first_failed_at',
|
|
'last_failed_at',
|
|
],
|
|
'cloud_instance_network_restrictions' => [
|
|
'instance_id', 'user_id', 'reason_code', 'desired_active',
|
|
'revision', 'source_type', 'source_id', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_instance_network_policy_states' => [
|
|
'instance_id', 'user_id', 'desired_suspended',
|
|
'applied_suspended', 'revision', 'state', 'operation_id',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_abuse_policy_revisions' => [
|
|
'id', 'revision', 'detector_version', 'policy_hash', 'active_slot',
|
|
'warmup_windows', 'suspicious_windows', 'high_windows',
|
|
'clear_windows', 'published_by', 'published_at', 'created_at',
|
|
],
|
|
'cloud_abuse_policy_rules' => [
|
|
'id', 'policy_revision_id', 'rule_code', 'direction', 'protocol',
|
|
'enabled', 'suspicious_thresholds_json',
|
|
'high_thresholds_json', 'created_at',
|
|
],
|
|
'cloud_abuse_instance_states' => [
|
|
'instance_id', 'user_id', 'host_id', 'rule_version',
|
|
'policy_revision', 'policy_hash', 'risk_state',
|
|
'collection_state', 'latest_direction', 'latest_rule_code',
|
|
'latest_severity', 'summary_json', 'last_projection_key',
|
|
'last_bucket_start', 'last_sample_at', 'last_evaluated_at',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_abuse_findings' => [
|
|
'id', 'finding_key', 'instance_id', 'user_id', 'host_id',
|
|
'rule_code', 'rule_version', 'policy_revision', 'policy_hash',
|
|
'direction', 'ip_family',
|
|
'severity', 'state', 'first_seen_at', 'last_seen_at',
|
|
'consecutive_windows', 'occurrence_generation',
|
|
'transition_revision', 'evidence_json', 'resolved_at',
|
|
'resolution_reason',
|
|
'created_at', 'updated_at',
|
|
],
|
|
'cloud_abuse_alert_events' => [
|
|
'id', 'event_key', 'sample_key', 'instance_id', 'user_id',
|
|
'host_id', 'bucket_start', 'rule_version', 'policy_revision',
|
|
'policy_hash', 'transition_digest', 'transition_count',
|
|
'highest_severity', 'created_at',
|
|
],
|
|
'cloud_abuse_alert_event_items' => [
|
|
'id', 'event_id', 'item_key', 'finding_key',
|
|
'occurrence_generation', 'transition_revision', 'rule_code',
|
|
'direction', 'ip_family', 'transition_type', 'from_severity',
|
|
'to_severity', 'evidence_json', 'resolution_reason',
|
|
'occurred_at', 'created_at',
|
|
],
|
|
'cloud_abuse_alert_deliveries' => [
|
|
'id', 'event_id', 'binding_generation', 'bound_admin_id',
|
|
'chat_id', 'telegram_message_id', 'state', 'message_text',
|
|
'content_hash', 'error_code', 'skip_reason',
|
|
'dispatch_started_at', 'sent_at', 'terminal_at',
|
|
'destination_redacted_at', 'created_at', 'updated_at',
|
|
],
|
|
'administrator_telegram_delivery_gate' => [
|
|
'id', 'next_send_at', 'updated_at',
|
|
],
|
|
'cloud_abuse_projection_receipts' => [
|
|
'sample_key', 'instance_id', 'rule_version', 'policy_revision',
|
|
'policy_hash', 'bucket_start', 'projected_at',
|
|
],
|
|
];
|
|
private const REQUIRED_LOG_COLUMNS = [
|
|
'cloud_vm_metric_samples' => [
|
|
'instance_id', 'user_id', 'sampled_at',
|
|
'cpu_percent', 'memory_used_mib', 'memory_total_mib',
|
|
'disk_read_bps', 'disk_write_bps', 'network_rx_bps',
|
|
'network_tx_bps', 'network_rx_bytes', 'network_tx_bytes',
|
|
],
|
|
'cloud_vm_metric_rollups' => [
|
|
'instance_id', 'user_id', 'interval_seconds', 'bucket_start',
|
|
'sample_count',
|
|
'last_sampled_at', 'cpu_percent_sum', 'cpu_percent_count',
|
|
'memory_used_mib_sum', 'memory_used_mib_count',
|
|
'memory_total_mib_sum', 'memory_total_mib_count',
|
|
'disk_read_bps_sum', 'disk_read_bps_count',
|
|
'disk_write_bps_sum', 'disk_write_bps_count',
|
|
'network_rx_bps_sum', 'network_rx_bps_count',
|
|
'network_tx_bps_sum', 'network_tx_bps_count',
|
|
],
|
|
'cloud_vm_traffic_totals' => [
|
|
'host_id', 'vm_uuid', 'user_id',
|
|
'last_observed_at', 'network_signature',
|
|
'network_baseline_json', 'download_rx_bytes',
|
|
'upload_tx_bytes', 'updated_at',
|
|
],
|
|
'cloud_vm_traffic_checkpoints' => [
|
|
'host_id', 'vm_uuid', 'checkpoint_hour', 'user_id',
|
|
'first_observed_at', 'download_rx_bytes',
|
|
'upload_tx_bytes',
|
|
],
|
|
'cloud_vm_daily_traffic_cursors' => [
|
|
'instance_id', 'user_id', 'last_observed_at',
|
|
'download_total_bytes', 'upload_total_bytes', 'updated_at',
|
|
],
|
|
'cloud_vm_daily_traffic' => [
|
|
'instance_id', 'user_id', 'day_start', 'download_bytes',
|
|
'upload_bytes', 'sample_count', 'first_observed_at',
|
|
'last_observed_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vm_network_observation_samples' => [
|
|
'sample_key', 'instance_id', 'user_id', 'host_id', 'vm_uuid',
|
|
'placement_key', 'collector_generation', 'window_id',
|
|
'contract_version', 'bucket_start', 'bucket_seconds',
|
|
'complete', 'metrics_json',
|
|
'quality_flags_json', 'received_at',
|
|
],
|
|
'cloud_vm_network_observation_rollups' => [
|
|
'instance_id', 'user_id', 'host_id', 'interval_seconds',
|
|
'bucket_start', 'sample_count', 'complete_count', 'quality_mask',
|
|
'rx_bytes_min', 'rx_bytes_max', 'tx_bytes_min', 'tx_bytes_max',
|
|
'rx_packets_min', 'rx_packets_max', 'tx_packets_min',
|
|
'tx_packets_max', 'tcp_active_peak', 'tcp_new_total',
|
|
'tcp_syn_total', 'tcp_unreplied_total', 'udp_active_peak',
|
|
'udp_new_total', 'peer_ip_cardinality_peak',
|
|
'peer_port_cardinality_peak',
|
|
'first_sample_at', 'last_sample_at', 'created_at', 'updated_at',
|
|
],
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'sample_key', 'instance_id', 'bucket_start', 'placement_key',
|
|
'rule_version', 'policy_revision', 'policy_hash', 'state',
|
|
'attempts', 'available_at', 'lease_token',
|
|
'lease_until', 'last_error_code', 'projected_at',
|
|
'terminal_at', 'discard_reason_code', 'created_at',
|
|
'updated_at',
|
|
],
|
|
'cloud_vm_network_monitor_cursors' => [
|
|
'host_id', 'collector_generation', 'cursor_value',
|
|
'oldest_cursor', 'gap_before', 'poll_revision',
|
|
'next_poll_at', 'poll_lease_token', 'poll_lease_until',
|
|
'collection_state', 'consecutive_failures',
|
|
'last_window_start', 'last_success_at', 'last_error_code',
|
|
'updated_at',
|
|
],
|
|
'cloud_vm_network_baselines' => [
|
|
'instance_id', 'user_id', 'rule_version', 'policy_revision',
|
|
'policy_hash', 'sample_count',
|
|
'warmup_state', 'metrics_json', 'last_projection_key',
|
|
'last_bucket_start', 'projection_lease_token',
|
|
'projection_lease_until', 'revision', 'created_at',
|
|
'updated_at',
|
|
],
|
|
];
|
|
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',
|
|
],
|
|
'cloud_storage_backends' => [
|
|
'chk_cloud_storage_backend_driver',
|
|
'chk_cloud_storage_backend_admin_state',
|
|
'chk_cloud_storage_backend_health_state',
|
|
'chk_cloud_storage_backend_revision',
|
|
],
|
|
'cloud_storage_artifacts' => [
|
|
'chk_cloud_storage_artifact_kind',
|
|
'chk_cloud_storage_artifact_policy',
|
|
'chk_cloud_storage_artifact_copies',
|
|
'chk_cloud_storage_artifact_identity',
|
|
'chk_cloud_storage_artifact_state',
|
|
],
|
|
'cloud_storage_publications' => [
|
|
'chk_cloud_storage_publication_owner',
|
|
'chk_cloud_storage_publication_state',
|
|
'chk_cloud_storage_publication_lease',
|
|
'chk_cloud_storage_publication_terminal',
|
|
'chk_cloud_storage_publication_coverage',
|
|
],
|
|
'cloud_storage_replicas' => [
|
|
'chk_cloud_storage_replica_role',
|
|
'chk_cloud_storage_replica_state',
|
|
'chk_cloud_storage_replica_ready',
|
|
],
|
|
'cloud_storage_operations' => [
|
|
'chk_cloud_storage_operation_kind',
|
|
'chk_cloud_storage_operation_phase',
|
|
'chk_cloud_storage_operation_outcome',
|
|
'chk_cloud_storage_operation_effect',
|
|
'chk_cloud_storage_operation_terminal',
|
|
],
|
|
'cloud_instance_backups' => [
|
|
'chk_cloud_instance_backup_create_request',
|
|
'chk_cloud_instance_backup_schedule_shape',
|
|
],
|
|
'cloud_public_ip_pool_catalog_mutex' => [
|
|
'chk_cloud_public_ip_pool_catalog_mutex',
|
|
],
|
|
'cloud_host_network_attachments' => [
|
|
'chk_cloud_network_attachment_state',
|
|
'chk_cloud_network_attachment_verification',
|
|
'chk_cloud_network_attachment_config_revision',
|
|
],
|
|
'cloud_public_ip_pools' => [
|
|
'chk_cloud_public_ip_pool_family',
|
|
'chk_cloud_public_ip_pool_prefix',
|
|
'chk_cloud_public_ip_pool_gateway',
|
|
'chk_cloud_public_ip_pool_allocation',
|
|
],
|
|
'cloud_public_ips' => [
|
|
'chk_cloud_public_ip_family', 'chk_cloud_public_ip_prefix',
|
|
'chk_cloud_public_ip_state',
|
|
'chk_cloud_public_ip_owner_shape',
|
|
],
|
|
'cloud_traffic_pool_groups' => [
|
|
'chk_cloud_traffic_pool_group_mode',
|
|
],
|
|
'cloud_service_periods' => [
|
|
'chk_cloud_period_traffic_quota_mode',
|
|
],
|
|
'cloud_traffic_pools' => [
|
|
'chk_cloud_traffic_pool_state',
|
|
],
|
|
'cloud_traffic_entitlements' => [
|
|
'chk_cloud_traffic_entitlement_window',
|
|
'chk_cloud_traffic_entitlement_mode',
|
|
'chk_cloud_traffic_entitlement_balance',
|
|
'chk_cloud_traffic_entitlement_state',
|
|
],
|
|
'cloud_traffic_usage_settlement_buckets' => [
|
|
'chk_cloud_traffic_settlement_identity',
|
|
'chk_cloud_traffic_settlement_bucket',
|
|
'chk_cloud_traffic_settlement_amount',
|
|
'chk_cloud_traffic_settlement_state',
|
|
],
|
|
'cloud_traffic_instance_cursors' => [
|
|
'chk_cloud_traffic_cursor_state',
|
|
],
|
|
'cloud_traffic_scan_failures' => [
|
|
'chk_cloud_traffic_scan_failure_kind',
|
|
],
|
|
'cloud_instance_network_restrictions' => [
|
|
'chk_cloud_network_restriction_reason',
|
|
],
|
|
'cloud_instance_network_policy_states' => [
|
|
'chk_cloud_network_policy_state',
|
|
],
|
|
'cloud_abuse_policy_revisions' => [
|
|
'chk_cloud_abuse_policy_hash',
|
|
'chk_cloud_abuse_policy_active',
|
|
'chk_cloud_abuse_policy_windows',
|
|
],
|
|
'cloud_abuse_policy_rules' => [
|
|
'chk_cloud_abuse_policy_rule_direction',
|
|
'chk_cloud_abuse_policy_rule_protocol',
|
|
'chk_cloud_abuse_policy_rule_enabled',
|
|
],
|
|
'cloud_abuse_instance_states' => [
|
|
'chk_cloud_abuse_state_risk',
|
|
'chk_cloud_abuse_state_collection',
|
|
'chk_cloud_abuse_state_direction',
|
|
'chk_cloud_abuse_state_severity',
|
|
'chk_cloud_abuse_state_policy',
|
|
'chk_cloud_abuse_state_projection',
|
|
],
|
|
'cloud_abuse_findings' => [
|
|
'chk_cloud_abuse_finding_key',
|
|
'chk_cloud_abuse_finding_direction',
|
|
'chk_cloud_abuse_finding_family',
|
|
'chk_cloud_abuse_finding_severity',
|
|
'chk_cloud_abuse_finding_state',
|
|
'chk_cloud_abuse_finding_policy',
|
|
'chk_cloud_abuse_finding_window',
|
|
'chk_cloud_abuse_finding_resolution',
|
|
],
|
|
'cloud_abuse_alert_events' => [
|
|
'chk_cloud_abuse_alert_event_identity',
|
|
'chk_cloud_abuse_alert_event_policy',
|
|
'chk_cloud_abuse_alert_event_shape',
|
|
],
|
|
'cloud_abuse_alert_event_items' => [
|
|
'chk_cloud_abuse_alert_item_identity',
|
|
'chk_cloud_abuse_alert_item_scope',
|
|
'chk_cloud_abuse_alert_item_transition',
|
|
],
|
|
'cloud_abuse_alert_deliveries' => [
|
|
'chk_cloud_abuse_alert_delivery_state',
|
|
'chk_cloud_abuse_alert_delivery_content',
|
|
'chk_cloud_abuse_alert_delivery_destination',
|
|
'chk_cloud_abuse_alert_delivery_shape',
|
|
],
|
|
'administrator_telegram_delivery_gate' => [
|
|
'chk_administrator_telegram_delivery_gate',
|
|
],
|
|
'cloud_abuse_projection_receipts' => [
|
|
'chk_cloud_abuse_projection_key',
|
|
'chk_cloud_abuse_projection_policy',
|
|
'chk_cloud_abuse_projection_bucket',
|
|
],
|
|
'cloud_template_import_intents' => [
|
|
'chk_cloud_template_import_source',
|
|
'chk_cloud_template_import_state',
|
|
'chk_cloud_template_import_completion',
|
|
],
|
|
'cloud_template_import_parts' => [
|
|
'chk_cloud_template_import_part',
|
|
],
|
|
'cloud_host_vpc_transports' => [
|
|
'chk_cloud_host_vpc_transport_prefix',
|
|
'chk_cloud_host_vpc_transport_mode',
|
|
'chk_cloud_host_vpc_transport_mtu',
|
|
'chk_cloud_host_vpc_transport_state',
|
|
'chk_cloud_host_vpc_transport_revision',
|
|
],
|
|
'cloud_vpc_cidr_pools' => [
|
|
'chk_cloud_vpc_cidr_pool_prefix',
|
|
'chk_cloud_vpc_cidr_pool_state',
|
|
],
|
|
'cloud_vpcs' => [
|
|
'chk_cloud_vpc_prefix', 'chk_cloud_vpc_active_claim',
|
|
'chk_cloud_vpc_state',
|
|
'chk_cloud_vpc_deleted_at',
|
|
],
|
|
'cloud_vpc_ports' => [
|
|
'chk_cloud_vpc_port_active_claim',
|
|
'chk_cloud_vpc_port_state', 'chk_cloud_vpc_port_release',
|
|
'chk_cloud_vpc_port_revision', 'chk_cloud_vpc_port_migration',
|
|
],
|
|
'cloud_vpc_host_states' => [
|
|
'chk_cloud_vpc_host_state', 'chk_cloud_vpc_host_revision',
|
|
],
|
|
'cloud_vpc_membership_batches' => [
|
|
'chk_cloud_vpc_membership_batch_kind',
|
|
'chk_cloud_vpc_membership_batch_state',
|
|
'chk_cloud_vpc_membership_batch_claim',
|
|
],
|
|
'cloud_vpc_membership_batch_items' => [
|
|
'chk_cloud_vpc_membership_batch_item_state',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batches' => [
|
|
'chk_cloud_public_pool_replacement_distinct',
|
|
'chk_cloud_public_pool_replacement_source_initial',
|
|
'chk_cloud_public_pool_replacement_state',
|
|
'chk_cloud_public_pool_replacement_claim',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batch_items' => [
|
|
'chk_cloud_public_pool_replacement_item_ip',
|
|
'chk_cloud_public_pool_replacement_item_family',
|
|
'chk_cloud_public_pool_replacement_item_state',
|
|
],
|
|
'cloud_backup_subscriptions' => [
|
|
'chk_cloud_backup_subscription_frequency',
|
|
'chk_cloud_backup_subscription_weekday',
|
|
'chk_cloud_backup_subscription_retention',
|
|
'chk_cloud_backup_subscription_deferral',
|
|
],
|
|
'cloud_backup_period_entitlements' => [
|
|
'chk_cloud_backup_entitlement_source',
|
|
'chk_cloud_backup_entitlement_window',
|
|
],
|
|
'cloud_deployment_snapshots' => [
|
|
'chk_cloud_deployment_snapshot_state',
|
|
],
|
|
'cloud_backup_restore_attempts' => [
|
|
'chk_cloud_backup_restore_attempt_generation',
|
|
'chk_cloud_backup_restore_attempt_active',
|
|
'chk_cloud_backup_restore_attempt_evidence',
|
|
'chk_cloud_backup_restore_attempt_plan',
|
|
'chk_cloud_backup_restore_attempt_state',
|
|
'chk_cloud_backup_restore_attempt_shape',
|
|
],
|
|
'cloud_backup_restores' => [
|
|
'chk_cloud_backup_restore_request',
|
|
],
|
|
'cloud_instance_migration_source_debts' => [
|
|
'chk_cloud_migration_source_debt_active',
|
|
'chk_cloud_migration_source_debt_state',
|
|
'chk_cloud_migration_source_debt_cleanup_pair',
|
|
'chk_cloud_migration_source_debt_shape',
|
|
],
|
|
'cloud_invoice_payments' => [
|
|
'chk_cloud_invoice_payment_status',
|
|
],
|
|
'cloud_maintenance_notices' => [
|
|
'chk_cloud_maintenance_notice_scope',
|
|
'chk_cloud_maintenance_notice_impact',
|
|
'chk_cloud_maintenance_notice_status',
|
|
'chk_cloud_maintenance_notice_window',
|
|
'chk_cloud_maintenance_notice_terminal',
|
|
],
|
|
'cloud_maintenance_notice_recipients' => [
|
|
'chk_cloud_maintenance_notice_recipient_status',
|
|
'chk_cloud_maintenance_notice_recipient_shape',
|
|
],
|
|
'cloud_service_compensations' => [
|
|
'chk_cloud_service_compensation_scope',
|
|
'chk_cloud_service_compensation_request',
|
|
'chk_cloud_service_compensation_window',
|
|
'chk_cloud_service_compensation_counts',
|
|
'chk_cloud_service_compensation_state',
|
|
'chk_cloud_service_compensation_terminal',
|
|
],
|
|
'cloud_service_compensation_items' => [
|
|
'chk_cloud_service_compensation_item_state',
|
|
'chk_cloud_service_compensation_item_window',
|
|
'chk_cloud_service_compensation_item_lease',
|
|
'chk_cloud_service_compensation_item_terminal',
|
|
'chk_cloud_service_compensation_item_applied',
|
|
'chk_cloud_service_compensation_item_error',
|
|
],
|
|
'cloud_service_compensation_recipients' => [
|
|
'chk_cloud_service_compensation_recipient_status',
|
|
'chk_cloud_service_compensation_recipient_payload',
|
|
'chk_cloud_service_compensation_recipient_shape',
|
|
],
|
|
'cloud_jobs' => [
|
|
'chk_cloud_job_dispatch_once', 'chk_cloud_job_attempt_shape',
|
|
'chk_cloud_job_phase', 'chk_cloud_job_outcome',
|
|
'chk_cloud_job_effect_resolution',
|
|
'chk_cloud_job_finalization_incident',
|
|
'chk_cloud_job_terminal_shape', 'chk_cloud_job_dispatch_shape',
|
|
'chk_cloud_job_target_shape', 'chk_cloud_job_effect_shape',
|
|
],
|
|
'cloud_resource_reservations' => [
|
|
'chk_cloud_resource_reservation_source',
|
|
],
|
|
'cloud_resource_reservation_ips' => [
|
|
'chk_cloud_reservation_ip_family',
|
|
'chk_cloud_reservation_ip_generation',
|
|
'chk_cloud_reservation_ip_active',
|
|
'chk_cloud_reservation_ip_state',
|
|
'chk_cloud_reservation_ip_release',
|
|
],
|
|
'cloud_public_network_transitions' => [
|
|
'chk_cloud_public_network_transition_kind',
|
|
'chk_cloud_public_network_transition_state',
|
|
'chk_cloud_public_network_transition_active',
|
|
'chk_cloud_public_network_transition_shape',
|
|
],
|
|
'cloud_public_network_transition_ips' => [
|
|
'chk_cloud_public_network_transition_ip_family',
|
|
'chk_cloud_public_network_transition_ip_changed',
|
|
'chk_cloud_public_network_transition_ip_target',
|
|
],
|
|
'cloud_agent_completion_events' => [
|
|
'chk_cloud_completion_outcome',
|
|
'chk_cloud_completion_disposition',
|
|
],
|
|
];
|
|
private const REQUIRED_LOG_CHECKS = [
|
|
'cloud_vm_metric_rollups' => [
|
|
'chk_vm_metric_rollup_bucket',
|
|
'chk_vm_metric_rollup_counts',
|
|
],
|
|
'cloud_vm_network_observation_rollups' => [
|
|
'chk_cloud_network_rollup_bucket',
|
|
'chk_cloud_network_rollup_counts',
|
|
'chk_cloud_network_rollup_counters',
|
|
],
|
|
'cloud_vm_network_observation_samples' => [
|
|
'chk_cloud_network_observation_contract',
|
|
'chk_cloud_network_observation_bucket',
|
|
'chk_cloud_network_observation_complete',
|
|
],
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'chk_cloud_network_projection_key',
|
|
'chk_cloud_network_projection_policy',
|
|
'chk_cloud_network_projection_state',
|
|
'chk_cloud_network_projection_lease',
|
|
],
|
|
'cloud_vm_network_monitor_cursors' => [
|
|
'chk_cloud_network_monitor_cursor_state',
|
|
'chk_cloud_network_monitor_cursor_generation',
|
|
'chk_cloud_network_monitor_cursor_lease',
|
|
],
|
|
'cloud_vm_network_baselines' => [
|
|
'chk_cloud_network_baseline_warmup',
|
|
'chk_cloud_network_baseline_policy',
|
|
'chk_cloud_network_baseline_projection',
|
|
'chk_cloud_network_baseline_projection_lease',
|
|
],
|
|
];
|
|
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',
|
|
],
|
|
'cloud_storage_backends' => [
|
|
'PRIMARY', 'cloud_storage_backend_key',
|
|
'cloud_storage_backend_identity', 'cloud_storage_backend_route',
|
|
'cloud_storage_backend_probe',
|
|
],
|
|
'cloud_storage_artifacts' => [
|
|
'PRIMARY', 'cloud_storage_artifact_key',
|
|
'cloud_storage_artifact_coverage',
|
|
'cloud_storage_artifact_operation',
|
|
],
|
|
'cloud_storage_replicas' => [
|
|
'PRIMARY', 'cloud_storage_replica_key',
|
|
'cloud_storage_replica_backend', 'cloud_storage_replica_object',
|
|
'cloud_storage_replica_due', 'cloud_storage_replica_lease',
|
|
'cloud_storage_replica_read',
|
|
],
|
|
'cloud_storage_operations' => [
|
|
'PRIMARY', 'cloud_storage_operation_id',
|
|
'cloud_storage_operation_request', 'cloud_storage_operation_poll',
|
|
'cloud_storage_operation_evidence',
|
|
'cloud_storage_operation_artifact',
|
|
],
|
|
'cloud_public_ip_pool_catalog_mutex' => [
|
|
'PRIMARY',
|
|
],
|
|
'cloud_host_network_attachments' => [
|
|
'PRIMARY', 'cloud_host_network_attachment_key',
|
|
'cloud_host_network_selector',
|
|
'cloud_host_network_attachment_line',
|
|
'cloud_network_attachment_sync',
|
|
'cloud_network_attachment_verification',
|
|
],
|
|
'cloud_public_ip_pools' => [
|
|
'PRIMARY', 'cloud_public_ip_pool_key',
|
|
'cloud_public_ip_pool_cidr',
|
|
'cloud_public_ip_pool_attachment',
|
|
'cloud_public_ip_pool_sync',
|
|
],
|
|
'cloud_public_ips' => [
|
|
'PRIMARY', 'cloud_public_ip_address',
|
|
'cloud_public_ip_available', 'cloud_public_ip_pool_available',
|
|
'cloud_public_ip_reservation', 'cloud_public_ip_claim',
|
|
'cloud_public_ip_instance',
|
|
'cloud_public_ip_operation',
|
|
],
|
|
'cloud_traffic_pool_groups' => [
|
|
'PRIMARY', 'cloud_traffic_pool_group_code',
|
|
'cloud_traffic_pool_group_mode',
|
|
],
|
|
'cloud_network_lines' => [
|
|
'cloud_network_line_traffic_pool_group',
|
|
],
|
|
'cloud_service_periods' => [
|
|
'cloud_period_traffic_pool',
|
|
],
|
|
'cloud_traffic_pools' => [
|
|
'PRIMARY', 'cloud_traffic_pool_owner_group',
|
|
'cloud_traffic_pool_state',
|
|
],
|
|
'cloud_traffic_entitlements' => [
|
|
'PRIMARY', 'cloud_traffic_entitlement_period',
|
|
'cloud_traffic_entitlement_fefo',
|
|
'cloud_traffic_entitlement_activation',
|
|
'cloud_traffic_entitlement_owner',
|
|
'cloud_traffic_entitlement_instance',
|
|
],
|
|
'cloud_traffic_ledger_events' => [
|
|
'PRIMARY', 'cloud_traffic_ledger_event_key',
|
|
'cloud_traffic_ledger_sequence', 'cloud_traffic_ledger_source',
|
|
'cloud_traffic_ledger_owner', 'cloud_traffic_ledger_instance',
|
|
'cloud_traffic_ledger_period', 'cloud_traffic_ledger_pool_time',
|
|
],
|
|
'cloud_traffic_usage_settlement_buckets' => [
|
|
'PRIMARY', 'cloud_traffic_settlement_identity',
|
|
'cloud_traffic_settlement_due',
|
|
'cloud_traffic_settlement_entitlement',
|
|
'cloud_traffic_settlement_owner',
|
|
'cloud_traffic_settlement_event',
|
|
],
|
|
'cloud_traffic_instance_cursors' => [
|
|
'PRIMARY', 'cloud_traffic_cursor_pool',
|
|
'cloud_traffic_cursor_owner',
|
|
],
|
|
'cloud_traffic_scan_failures' => [
|
|
'PRIMARY', 'cloud_traffic_scan_failure_subject',
|
|
'cloud_traffic_scan_failure_retry',
|
|
],
|
|
'cloud_instance_network_restrictions' => [
|
|
'PRIMARY', 'cloud_network_restriction_desired',
|
|
'cloud_network_restriction_owner',
|
|
],
|
|
'cloud_instance_network_policy_states' => [
|
|
'PRIMARY', 'cloud_network_policy_operation',
|
|
'cloud_network_policy_state', 'cloud_network_policy_owner',
|
|
],
|
|
'cloud_abuse_policy_revisions' => [
|
|
'PRIMARY', 'cloud_abuse_policy_revision',
|
|
'cloud_abuse_policy_active', 'cloud_abuse_policy_hash',
|
|
],
|
|
'cloud_abuse_policy_rules' => [
|
|
'PRIMARY', 'cloud_abuse_policy_rule_revision',
|
|
'cloud_abuse_policy_rule_code',
|
|
],
|
|
'cloud_abuse_instance_states' => [
|
|
'PRIMARY', 'cloud_abuse_state_risk',
|
|
'cloud_abuse_state_collection', 'cloud_abuse_state_host',
|
|
'cloud_abuse_state_owner',
|
|
],
|
|
'cloud_abuse_findings' => [
|
|
'PRIMARY', 'cloud_abuse_finding_key',
|
|
'cloud_abuse_finding_instance', 'cloud_abuse_finding_owner',
|
|
'cloud_abuse_finding_host', 'cloud_abuse_finding_rule',
|
|
'cloud_abuse_finding_retention',
|
|
],
|
|
'cloud_abuse_alert_events' => [
|
|
'PRIMARY', 'cloud_abuse_alert_event_key',
|
|
'cloud_abuse_alert_event_sample',
|
|
'cloud_abuse_alert_event_instance',
|
|
'cloud_abuse_alert_event_owner',
|
|
'cloud_abuse_alert_event_host',
|
|
'cloud_abuse_alert_event_retention',
|
|
],
|
|
'cloud_abuse_alert_event_items' => [
|
|
'PRIMARY', 'cloud_abuse_alert_item_key',
|
|
'cloud_abuse_alert_item_finding_once',
|
|
'cloud_abuse_alert_item_event',
|
|
'cloud_abuse_alert_item_finding',
|
|
],
|
|
'cloud_abuse_alert_deliveries' => [
|
|
'PRIMARY', 'cloud_abuse_alert_delivery_event',
|
|
'cloud_abuse_alert_delivery_message',
|
|
'cloud_abuse_alert_delivery_due',
|
|
'cloud_abuse_alert_delivery_admin',
|
|
'cloud_abuse_alert_delivery_terminal',
|
|
],
|
|
'administrator_telegram_delivery_gate' => ['PRIMARY'],
|
|
'cloud_abuse_projection_receipts' => [
|
|
'PRIMARY', 'cloud_abuse_projection_instance',
|
|
'cloud_abuse_projection_retention',
|
|
],
|
|
'cloud_template_import_intents' => [
|
|
'PRIMARY', 'cloud_template_import_request',
|
|
'cloud_template_import_template',
|
|
'cloud_template_import_generation',
|
|
'cloud_template_import_object', 'cloud_template_import_state',
|
|
'cloud_template_import_job',
|
|
],
|
|
'cloud_template_import_parts' => [
|
|
'PRIMARY', 'cloud_template_import_part_order',
|
|
],
|
|
'cloud_template_artifacts' => [
|
|
'PRIMARY', 'cloud_template_artifact_object',
|
|
'cloud_template_artifact_storage',
|
|
'cloud_template_artifact_state',
|
|
'cloud_template_artifact_delete_due',
|
|
],
|
|
'cloud_template_replicas' => [
|
|
'PRIMARY', 'cloud_template_replica_ready',
|
|
'cloud_template_replica_observed',
|
|
],
|
|
'cloud_rescue_templates' => [
|
|
'PRIMARY', 'cloud_rescue_template_generation',
|
|
'cloud_rescue_template_catalog',
|
|
],
|
|
'cloud_rescue_template_artifacts' => [
|
|
'PRIMARY', 'cloud_rescue_artifact_object',
|
|
'cloud_rescue_artifact_storage',
|
|
'cloud_rescue_artifact_state',
|
|
'cloud_rescue_artifact_delete_due',
|
|
],
|
|
'cloud_rescue_template_replicas' => [
|
|
'PRIMARY', 'cloud_rescue_replica_ready',
|
|
'cloud_rescue_replica_observed',
|
|
'cloud_rescue_replica_cleanup',
|
|
],
|
|
'cloud_host_vpc_transports' => [
|
|
'PRIMARY', 'cloud_host_vpc_transport_operation',
|
|
'cloud_host_vpc_transport_state',
|
|
],
|
|
'cloud_vpc_cidr_pools' => [
|
|
'PRIMARY', 'cloud_vpc_cidr_pool_key',
|
|
'cloud_vpc_cidr_pool_region', 'cloud_vpc_cidr_pool_catalog',
|
|
],
|
|
'cloud_vpcs' => [
|
|
'PRIMARY', 'cloud_vpc_key', 'cloud_vpc_region_cidr',
|
|
'cloud_vpc_owner', 'cloud_vpc_region_state',
|
|
'cloud_vpc_pool_state',
|
|
],
|
|
'cloud_vpc_ports' => [
|
|
'PRIMARY', 'cloud_vpc_port_key', 'cloud_vpc_port_ip_claim',
|
|
'cloud_vpc_port_instance_claim', 'cloud_vpc_port_mac',
|
|
'cloud_vpc_port_operation', 'cloud_vpc_port_owner',
|
|
'cloud_vpc_port_vpc_state',
|
|
],
|
|
'cloud_vpc_host_states' => [
|
|
'PRIMARY', 'cloud_vpc_host_identity',
|
|
'cloud_vpc_host_operation', 'cloud_vpc_host_sync',
|
|
],
|
|
'cloud_vpc_membership_batches' => [
|
|
'PRIMARY', 'cloud_vpc_membership_batch_key',
|
|
'cloud_vpc_membership_batch_job',
|
|
'cloud_vpc_membership_batch_active',
|
|
'cloud_vpc_membership_batch_owner',
|
|
],
|
|
'cloud_vpc_membership_batch_items' => [
|
|
'PRIMARY', 'cloud_vpc_membership_batch_instance',
|
|
'cloud_vpc_membership_batch_port',
|
|
'cloud_vpc_membership_batch_child',
|
|
'cloud_vpc_membership_batch_item_owner',
|
|
'cloud_vpc_membership_batch_item_state',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batches' => [
|
|
'PRIMARY', 'cloud_public_pool_replacement_key',
|
|
'cloud_public_pool_replacement_job',
|
|
'cloud_public_pool_replacement_active',
|
|
'cloud_public_pool_replacement_host',
|
|
'cloud_public_pool_replacement_target',
|
|
],
|
|
'cloud_public_ip_pool_replacement_batch_items' => [
|
|
'PRIMARY', 'cloud_public_pool_replacement_instance',
|
|
'cloud_public_pool_replacement_child',
|
|
'cloud_public_pool_replacement_target_ip',
|
|
'cloud_public_pool_replacement_item_state',
|
|
],
|
|
'cloud_maintenance_notices' => [
|
|
'PRIMARY', 'cloud_maintenance_notice_key',
|
|
'cloud_maintenance_notice_request',
|
|
'cloud_maintenance_notice_delivery',
|
|
'cloud_maintenance_notice_scope',
|
|
],
|
|
'cloud_maintenance_notice_instances' => [
|
|
'PRIMARY', 'cloud_maintenance_notice_instance',
|
|
'cloud_maintenance_notice_instance_owner',
|
|
'cloud_maintenance_notice_instance_source',
|
|
],
|
|
'cloud_maintenance_notice_recipients' => [
|
|
'PRIMARY', 'cloud_maintenance_notice_recipient',
|
|
'cloud_maintenance_notice_recipient_due',
|
|
'cloud_maintenance_notice_recipient_lease',
|
|
'cloud_maintenance_notice_recipient_owner',
|
|
],
|
|
'cloud_service_compensations' => [
|
|
'PRIMARY', 'cloud_service_compensation_key',
|
|
'cloud_service_compensation_request',
|
|
'cloud_service_compensation_incident_identity',
|
|
'cloud_service_compensation_incident',
|
|
'cloud_service_compensation_scope',
|
|
'cloud_service_compensation_state',
|
|
],
|
|
'cloud_service_compensation_items' => [
|
|
'PRIMARY', 'cloud_service_compensation_item_key',
|
|
'cloud_service_compensation_item_instance',
|
|
'cloud_service_compensation_item_incident',
|
|
'cloud_service_compensation_item_batch_state',
|
|
'cloud_service_compensation_item_due',
|
|
'cloud_service_compensation_item_lease',
|
|
'cloud_service_compensation_item_open',
|
|
'cloud_service_compensation_item_owner',
|
|
'cloud_service_compensation_item_instance_history',
|
|
'cloud_service_compensation_item_audit_job',
|
|
],
|
|
'cloud_service_compensation_recipients' => [
|
|
'PRIMARY', 'cloud_service_compensation_recipient',
|
|
'cloud_service_compensation_recipient_due',
|
|
'cloud_service_compensation_recipient_lease',
|
|
'cloud_service_compensation_recipient_owner',
|
|
],
|
|
'cloud_jobs' => [
|
|
'PRIMARY', 'uniq_cloud_operation', 'uniq_cloud_job_request',
|
|
'uniq_cloud_job_completion_event', 'uniq_cloud_provision_order',
|
|
'cloud_job_poll', 'cloud_job_receipt_deadline',
|
|
'cloud_job_backup', 'cloud_job_backup_restore',
|
|
'cloud_job_backup_recovery',
|
|
'cloud_job_public_network_transition',
|
|
'cloud_job_vpc', 'cloud_job_vpc_port', 'cloud_job_vpc_batch',
|
|
'cloud_job_supersedes', 'cloud_job_vpc_repair_root',
|
|
],
|
|
'cloud_agent_completion_events' => [
|
|
'PRIMARY', 'uniq_cloud_completion_operation',
|
|
],
|
|
'cloud_resource_reservation_ips' => [
|
|
'PRIMARY', 'cloud_reservation_ip_active',
|
|
'cloud_reservation_ip_generation',
|
|
'cloud_reservation_ip_operation',
|
|
'cloud_reservation_ip_address', 'cloud_reservation_ip_pool',
|
|
'cloud_reservation_ip_attachment',
|
|
],
|
|
'cloud_public_network_transitions' => [
|
|
'PRIMARY', 'cloud_public_network_transition_key',
|
|
'cloud_public_network_transition_operation',
|
|
'cloud_public_network_transition_active_instance',
|
|
'cloud_public_network_transition_active_reservation',
|
|
'cloud_public_network_transition_host_state',
|
|
'cloud_public_network_transition_invoice',
|
|
'cloud_public_network_transition_batch_item',
|
|
],
|
|
'cloud_public_network_transition_ips' => [
|
|
'PRIMARY', 'cloud_public_network_transition_ip_family',
|
|
'cloud_public_network_transition_ip_target',
|
|
'cloud_public_network_transition_ip_source',
|
|
],
|
|
'cloud_backup_subscriptions' => [
|
|
'PRIMARY', 'cloud_backup_subscription_instance',
|
|
'cloud_backup_subscription_due',
|
|
'cloud_backup_subscription_owner',
|
|
],
|
|
'cloud_backup_period_entitlements' => [
|
|
'PRIMARY', 'cloud_backup_entitlement_period',
|
|
'cloud_backup_entitlement_subscription',
|
|
'cloud_backup_entitlement_instance',
|
|
'cloud_backup_entitlement_owner',
|
|
'cloud_backup_entitlement_invoice',
|
|
],
|
|
'cloud_instance_backups' => [
|
|
'PRIMARY', 'cloud_instance_backup_key',
|
|
'cloud_instance_backup_create_request',
|
|
'cloud_instance_backup_storage',
|
|
'cloud_instance_backup_object', 'cloud_instance_backup_schedule',
|
|
'cloud_instance_backup_source',
|
|
'cloud_instance_backup_owner', 'cloud_instance_backup_operation',
|
|
'cloud_instance_backup_delete_due',
|
|
],
|
|
'cloud_storage_publications' => [
|
|
'PRIMARY', 'cloud_storage_publication_key',
|
|
'cloud_storage_publication_artifact',
|
|
'cloud_storage_publication_backup',
|
|
'cloud_storage_publication_template_import',
|
|
'cloud_storage_publication_rescue',
|
|
'cloud_storage_publication_due',
|
|
'cloud_storage_publication_lease',
|
|
],
|
|
'cloud_deployment_snapshots' => [
|
|
'PRIMARY', 'cloud_deployment_snapshot_key',
|
|
'cloud_deployment_snapshot_backup',
|
|
'cloud_deployment_snapshot_request',
|
|
'cloud_deployment_snapshot_owner',
|
|
'cloud_deployment_snapshot_source',
|
|
],
|
|
'cloud_orders' => [
|
|
'cloud_order_deployment_snapshot',
|
|
],
|
|
'cloud_backup_restores' => [
|
|
'PRIMARY', 'cloud_backup_restore_key',
|
|
'cloud_backup_restore_request',
|
|
'cloud_backup_restore_operation',
|
|
'cloud_backup_restore_reservation',
|
|
'cloud_backup_restore_instance', 'cloud_backup_restore_backup',
|
|
'cloud_backup_restore_host',
|
|
],
|
|
'cloud_backup_restore_attempts' => [
|
|
'PRIMARY', 'cloud_backup_restore_attempt_key',
|
|
'cloud_backup_restore_attempt_operation',
|
|
'cloud_backup_restore_attempt_generation',
|
|
'cloud_backup_restore_attempt_active',
|
|
'cloud_backup_restore_attempt_job',
|
|
'cloud_backup_restore_attempt_reservation',
|
|
'cloud_backup_restore_attempt_host',
|
|
],
|
|
'cloud_backup_recoveries' => [
|
|
'PRIMARY', 'cloud_backup_recovery_key',
|
|
'cloud_backup_recovery_operation', 'cloud_backup_recovery_job',
|
|
'cloud_backup_recovery_instance', 'cloud_backup_recovery_backup',
|
|
],
|
|
'cloud_order_items' => [
|
|
'PRIMARY', 'cloud_order_item_code', 'cloud_order_item_order',
|
|
],
|
|
'cloud_invoice_items' => [
|
|
'PRIMARY', 'cloud_invoice_item_code',
|
|
'cloud_invoice_item_invoice', 'cloud_invoice_item_order_item',
|
|
],
|
|
'cloud_instance_migrations' => [
|
|
'PRIMARY', 'cloud_instance_migration_key',
|
|
'cloud_instance_migration_restore',
|
|
'cloud_instance_migration_prepare_job',
|
|
'cloud_instance_migration_receive_job',
|
|
'cloud_instance_migration_firewall_job',
|
|
'cloud_instance_migration_activate_job',
|
|
'cloud_instance_migration_rollback_job',
|
|
'cloud_instance_migration_cleanup_job',
|
|
'cloud_instance_migration_instance',
|
|
'cloud_instance_migration_vpc_port',
|
|
'cloud_instance_migration_source',
|
|
'cloud_instance_migration_target',
|
|
],
|
|
'cloud_instance_migration_source_debts' => [
|
|
'PRIMARY', 'cloud_migration_source_debt_key',
|
|
'cloud_migration_source_debt_migration',
|
|
'cloud_migration_source_debt_active_reservation',
|
|
'cloud_migration_source_debt_cleanup_operation',
|
|
'cloud_migration_source_debt_cleanup_job',
|
|
'cloud_migration_source_debt_host',
|
|
],
|
|
'cloud_peer_migration_artifacts' => [
|
|
'PRIMARY', 'cloud_peer_migration_artifact',
|
|
'cloud_peer_migration_snapshot',
|
|
'cloud_peer_migration_source_snapshot',
|
|
'cloud_peer_migration_state',
|
|
],
|
|
'cloud_resource_reservations' => [
|
|
'PRIMARY', 'cloud_resource_reservation_key',
|
|
'cloud_resource_reservation_operation',
|
|
'cloud_resource_reservation_order',
|
|
'cloud_resource_reservation_backup_restore',
|
|
'cloud_resource_reservation_backup_attempt',
|
|
'cloud_resource_reservation_migration_debt',
|
|
'cloud_resource_reservation_host',
|
|
'cloud_resource_reservation_pool',
|
|
'cloud_resource_reservation_instance',
|
|
'cloud_resource_reservation_network',
|
|
'cloud_resource_reservation_ip',
|
|
],
|
|
];
|
|
private const REQUIRED_LOG_INDEXES = [
|
|
'cloud_vm_metric_samples' => [
|
|
'PRIMARY', 'vm_metric_retention', 'vm_metric_owner',
|
|
],
|
|
'cloud_vm_metric_rollups' => [
|
|
'PRIMARY', 'vm_metric_rollup_retention',
|
|
'vm_metric_rollup_owner',
|
|
],
|
|
'cloud_vm_traffic_totals' => [
|
|
'PRIMARY', 'vm_traffic_uuid', 'vm_traffic_owner',
|
|
],
|
|
'cloud_vm_traffic_checkpoints' => [
|
|
'PRIMARY', 'vm_traffic_checkpoint_owner',
|
|
],
|
|
'cloud_vm_network_observation_rollups' => [
|
|
'PRIMARY', 'cloud_network_rollup_owner',
|
|
'cloud_network_rollup_host', 'cloud_network_rollup_retention',
|
|
],
|
|
'cloud_vm_network_observation_samples' => [
|
|
'PRIMARY', 'cloud_network_observation_source',
|
|
'cloud_network_observation_instance',
|
|
'cloud_network_observation_retention',
|
|
],
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'PRIMARY', 'cloud_network_projection_due',
|
|
'cloud_network_projection_instance',
|
|
'cloud_network_projection_lease',
|
|
'cloud_network_projection_retention',
|
|
],
|
|
'cloud_vm_network_monitor_cursors' => [
|
|
'PRIMARY', 'cloud_network_monitor_cursor_health',
|
|
'cloud_network_monitor_cursor_due',
|
|
'cloud_network_monitor_cursor_lease',
|
|
],
|
|
'cloud_vm_network_baselines' => [
|
|
'PRIMARY', 'cloud_network_baseline_owner',
|
|
'cloud_network_baseline_warmup',
|
|
'cloud_network_baseline_projection_lease',
|
|
],
|
|
];
|
|
/**
|
|
* Safety-critical indexes whose name alone is not a sufficient contract.
|
|
* `non_unique` mirrors information_schema.STATISTICS: 0 is unique, 1 is
|
|
* 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_traffic_usage_settlement_buckets' => [
|
|
'cloud_traffic_settlement_identity' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'pool_id', 'instance_id', 'service_period_id',
|
|
'allocation_kind', 'allocation_target_id',
|
|
'bucket_start', 'bucket_revision',
|
|
],
|
|
],
|
|
'cloud_traffic_settlement_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'bucket_start', 'id'],
|
|
],
|
|
],
|
|
'cloud_instance_backups' => [
|
|
'cloud_instance_backup_create_request' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'create_request_actor_id',
|
|
'create_request_idempotency_key',
|
|
],
|
|
],
|
|
],
|
|
'cloud_maintenance_notices' => [
|
|
'cloud_maintenance_notice_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['notice_key'],
|
|
],
|
|
'cloud_maintenance_notice_request' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'requested_by_user_id', 'request_idempotency_key',
|
|
],
|
|
],
|
|
'cloud_maintenance_notice_delivery' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['status', 'scheduled_at', 'id'],
|
|
],
|
|
],
|
|
'cloud_maintenance_notice_instances' => [
|
|
'cloud_maintenance_notice_instance' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['notice_id', 'instance_id'],
|
|
],
|
|
'cloud_maintenance_notice_instance_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['notice_id', 'user_id', 'id'],
|
|
],
|
|
],
|
|
'cloud_maintenance_notice_recipients' => [
|
|
'cloud_maintenance_notice_recipient' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['notice_id', 'user_id'],
|
|
],
|
|
'cloud_maintenance_notice_recipient_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['status', 'available_at', 'id'],
|
|
],
|
|
'cloud_maintenance_notice_recipient_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['status', 'lease_until', 'id'],
|
|
],
|
|
],
|
|
'cloud_service_compensations' => [
|
|
'cloud_service_compensation_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['compensation_key'],
|
|
],
|
|
'cloud_service_compensation_request' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'requested_by_user_id', 'request_idempotency_key',
|
|
],
|
|
],
|
|
'cloud_service_compensation_incident_identity' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['id', 'incident_key'],
|
|
],
|
|
],
|
|
'cloud_service_compensation_items' => [
|
|
'cloud_service_compensation_item_instance' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['batch_id', 'instance_id'],
|
|
],
|
|
'cloud_service_compensation_item_incident' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['incident_key', 'instance_id'],
|
|
],
|
|
'cloud_service_compensation_item_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'available_at', 'id'],
|
|
],
|
|
'cloud_service_compensation_item_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'lease_until', 'id'],
|
|
],
|
|
'cloud_service_compensation_item_open' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['instance_id', 'state', 'id'],
|
|
],
|
|
],
|
|
'cloud_service_compensation_recipients' => [
|
|
'cloud_service_compensation_recipient' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['batch_id', 'user_id'],
|
|
],
|
|
'cloud_service_compensation_recipient_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['status', 'available_at', 'id'],
|
|
],
|
|
'cloud_service_compensation_recipient_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['status', 'lease_until', 'id'],
|
|
],
|
|
],
|
|
'cloud_backup_restores' => [
|
|
'cloud_backup_restore_request' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'requested_by_user_id', 'request_idempotency_key',
|
|
],
|
|
],
|
|
],
|
|
'cloud_backup_restore_attempts' => [
|
|
'cloud_backup_restore_attempt_generation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['backup_restore_id', 'generation'],
|
|
],
|
|
'cloud_backup_restore_attempt_active' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['backup_restore_id', 'active_attempt'],
|
|
],
|
|
'cloud_backup_restore_attempt_operation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['operation_id'],
|
|
],
|
|
'cloud_backup_restore_attempt_reservation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['reservation_id'],
|
|
],
|
|
],
|
|
'cloud_instance_migration_source_debts' => [
|
|
'cloud_migration_source_debt_migration' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['migration_id'],
|
|
],
|
|
'cloud_migration_source_debt_active_reservation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['source_reservation_id', 'active_debt'],
|
|
],
|
|
'cloud_migration_source_debt_cleanup_operation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['cleanup_operation_id'],
|
|
],
|
|
],
|
|
'cloud_resource_reservations' => [
|
|
'cloud_resource_reservation_backup_attempt' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['backup_restore_attempt_key'],
|
|
],
|
|
'cloud_resource_reservation_migration_debt' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['migration_source_debt_id'],
|
|
],
|
|
],
|
|
'cloud_public_ips' => [
|
|
'cloud_public_ip_reservation' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'reservation_id', 'address_family', 'state', 'id',
|
|
],
|
|
],
|
|
'cloud_public_ip_claim' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['reservation_ip_claim_id'],
|
|
],
|
|
'cloud_public_ip_operation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['operation_id', 'address_family'],
|
|
],
|
|
],
|
|
'cloud_resource_reservation_ips' => [
|
|
'cloud_reservation_ip_active' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'reservation_id', 'address_family', 'active_claim',
|
|
],
|
|
],
|
|
'cloud_reservation_ip_generation' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'reservation_id', 'claim_generation', 'address_family',
|
|
],
|
|
],
|
|
'cloud_reservation_ip_operation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['operation_id', 'address_family'],
|
|
],
|
|
],
|
|
'cloud_public_network_transitions' => [
|
|
'cloud_public_network_transition_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['transition_key'],
|
|
],
|
|
'cloud_public_network_transition_operation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['operation_id'],
|
|
],
|
|
'cloud_public_network_transition_active_instance' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['instance_id', 'active_transition'],
|
|
],
|
|
'cloud_public_network_transition_active_reservation' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['reservation_id', 'active_transition'],
|
|
],
|
|
'cloud_public_network_transition_invoice' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['invoice_id'],
|
|
],
|
|
'cloud_public_network_transition_batch_item' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['pool_replacement_batch_item_id'],
|
|
],
|
|
],
|
|
'cloud_public_network_transition_ips' => [
|
|
'cloud_public_network_transition_ip_family' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['transition_id', 'address_family'],
|
|
],
|
|
'cloud_public_network_transition_ip_target' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['target_claim_id'],
|
|
],
|
|
],
|
|
'cloud_abuse_policy_revisions' => [
|
|
'cloud_abuse_policy_revision' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['revision'],
|
|
],
|
|
'cloud_abuse_policy_active' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['active_slot'],
|
|
],
|
|
'cloud_abuse_policy_hash' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['policy_hash', 'revision'],
|
|
],
|
|
],
|
|
'cloud_abuse_policy_rules' => [
|
|
'cloud_abuse_policy_rule_revision' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['policy_revision_id', 'rule_code'],
|
|
],
|
|
'cloud_abuse_policy_rule_code' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['rule_code', 'policy_revision_id'],
|
|
],
|
|
],
|
|
'cloud_abuse_findings' => [
|
|
'cloud_abuse_finding_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['finding_key'],
|
|
],
|
|
'cloud_abuse_finding_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'state', 'resolved_at', 'last_seen_at', 'id',
|
|
],
|
|
],
|
|
],
|
|
'cloud_abuse_alert_events' => [
|
|
'cloud_abuse_alert_event_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['event_key'],
|
|
],
|
|
'cloud_abuse_alert_event_sample' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['sample_key'],
|
|
],
|
|
'cloud_abuse_alert_event_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['created_at', 'id'],
|
|
],
|
|
],
|
|
'cloud_abuse_alert_event_items' => [
|
|
'cloud_abuse_alert_item_key' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['item_key'],
|
|
],
|
|
'cloud_abuse_alert_item_finding_once' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['event_id', 'finding_key'],
|
|
],
|
|
'cloud_abuse_alert_item_event' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['event_id', 'id'],
|
|
],
|
|
],
|
|
'cloud_abuse_alert_deliveries' => [
|
|
'cloud_abuse_alert_delivery_event' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['event_id'],
|
|
],
|
|
'cloud_abuse_alert_delivery_message' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'binding_generation', 'chat_id',
|
|
'telegram_message_id',
|
|
],
|
|
],
|
|
'cloud_abuse_alert_delivery_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'updated_at', 'id'],
|
|
],
|
|
'cloud_abuse_alert_delivery_terminal' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['terminal_at', 'state', 'id'],
|
|
],
|
|
],
|
|
'cloud_abuse_projection_receipts' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['sample_key'],
|
|
],
|
|
'cloud_abuse_projection_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['projected_at', 'sample_key'],
|
|
],
|
|
],
|
|
'cloud_jobs' => [
|
|
'cloud_job_public_network_transition' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['public_network_transition_id'],
|
|
],
|
|
],
|
|
];
|
|
private const REQUIRED_LOG_INDEX_SHAPES = [
|
|
'cloud_vm_metric_samples' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['instance_id', 'sampled_at'],
|
|
],
|
|
'vm_metric_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['user_id', 'sampled_at', 'instance_id'],
|
|
],
|
|
],
|
|
'cloud_vm_metric_rollups' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['instance_id', 'interval_seconds', 'bucket_start'],
|
|
],
|
|
'vm_metric_rollup_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'interval_seconds', 'bucket_start', 'instance_id',
|
|
],
|
|
],
|
|
],
|
|
'cloud_vm_traffic_totals' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['host_id', 'vm_uuid'],
|
|
],
|
|
'vm_traffic_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['user_id', 'host_id'],
|
|
],
|
|
'vm_traffic_uuid' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['vm_uuid', 'host_id'],
|
|
],
|
|
],
|
|
'cloud_vm_traffic_checkpoints' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['host_id', 'vm_uuid', 'checkpoint_hour'],
|
|
],
|
|
'vm_traffic_checkpoint_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['user_id', 'host_id', 'first_observed_at'],
|
|
],
|
|
],
|
|
'cloud_vm_network_observation_rollups' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'instance_id', 'interval_seconds', 'bucket_start',
|
|
],
|
|
],
|
|
'cloud_network_rollup_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'user_id', 'interval_seconds', 'bucket_start',
|
|
'instance_id',
|
|
],
|
|
],
|
|
'cloud_network_rollup_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'interval_seconds', 'bucket_start', 'instance_id',
|
|
],
|
|
],
|
|
],
|
|
'cloud_vm_network_observation_samples' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['sample_key'],
|
|
],
|
|
'cloud_network_observation_source' => [
|
|
'non_unique' => 0,
|
|
'columns' => [
|
|
'host_id', 'collector_generation', 'window_id', 'vm_uuid',
|
|
],
|
|
],
|
|
'cloud_network_observation_instance' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['instance_id', 'bucket_start'],
|
|
],
|
|
'cloud_network_observation_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['bucket_start'],
|
|
],
|
|
],
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['sample_key'],
|
|
],
|
|
'cloud_network_projection_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'state', 'available_at', 'bucket_start', 'sample_key',
|
|
],
|
|
],
|
|
'cloud_network_projection_instance' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'instance_id', 'state', 'bucket_start', 'sample_key',
|
|
],
|
|
],
|
|
'cloud_network_projection_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'lease_until', 'sample_key'],
|
|
],
|
|
'cloud_network_projection_retention' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['state', 'terminal_at', 'sample_key'],
|
|
],
|
|
],
|
|
'cloud_vm_network_monitor_cursors' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['host_id'],
|
|
],
|
|
'cloud_network_monitor_cursor_health' => [
|
|
'non_unique' => 1,
|
|
'columns' => [
|
|
'collection_state', 'last_success_at', 'host_id',
|
|
],
|
|
],
|
|
'cloud_network_monitor_cursor_due' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['next_poll_at', 'poll_revision', 'host_id'],
|
|
],
|
|
'cloud_network_monitor_cursor_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['poll_lease_until', 'host_id'],
|
|
],
|
|
],
|
|
'cloud_vm_network_baselines' => [
|
|
'PRIMARY' => [
|
|
'non_unique' => 0,
|
|
'columns' => ['instance_id'],
|
|
],
|
|
'cloud_network_baseline_owner' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['user_id', 'updated_at'],
|
|
],
|
|
'cloud_network_baseline_warmup' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['warmup_state', 'sample_count'],
|
|
],
|
|
'cloud_network_baseline_projection_lease' => [
|
|
'non_unique' => 1,
|
|
'columns' => ['projection_lease_until', 'instance_id'],
|
|
],
|
|
],
|
|
];
|
|
private const REQUIRED_FOREIGN_KEYS = [
|
|
'cloud_abuse_policy_rules' => [
|
|
'fk_cloud_abuse_policy_rule_revision',
|
|
],
|
|
'cloud_abuse_instance_states' => [
|
|
'fk_cloud_abuse_state_instance',
|
|
],
|
|
'cloud_abuse_findings' => [
|
|
'fk_cloud_abuse_finding_instance',
|
|
],
|
|
'cloud_abuse_alert_event_items' => [
|
|
'fk_cloud_abuse_alert_item_event',
|
|
],
|
|
'cloud_abuse_alert_deliveries' => [
|
|
'fk_cloud_abuse_alert_delivery_event',
|
|
],
|
|
'cloud_abuse_projection_receipts' => [
|
|
'fk_cloud_abuse_projection_instance',
|
|
],
|
|
'cloud_storage_replicas' => [
|
|
'fk_cloud_storage_replica_artifact',
|
|
'fk_cloud_storage_replica_backend',
|
|
],
|
|
'cloud_storage_operations' => [
|
|
'fk_cloud_storage_operation_artifact',
|
|
'fk_cloud_storage_operation_replica',
|
|
'fk_cloud_storage_operation_source_backend',
|
|
'fk_cloud_storage_operation_target_backend',
|
|
],
|
|
'cloud_template_artifacts' => [
|
|
'fk_cloud_template_artifact_storage',
|
|
],
|
|
'cloud_rescue_template_artifacts' => [
|
|
'fk_cloud_rescue_artifact_storage',
|
|
],
|
|
'cloud_instance_backups' => [
|
|
'fk_cloud_instance_backup_storage',
|
|
],
|
|
'cloud_storage_publications' => [
|
|
'fk_cloud_storage_publication_artifact',
|
|
'fk_cloud_storage_publication_backup',
|
|
'fk_cloud_storage_publication_template_import',
|
|
'fk_cloud_storage_publication_rescue',
|
|
],
|
|
'cloud_template_import_intents' => [
|
|
'fk_cloud_template_import_user',
|
|
],
|
|
'cloud_template_import_parts' => [
|
|
'fk_cloud_template_import_part_intent',
|
|
],
|
|
'cloud_maintenance_notice_instances' => [
|
|
'fk_cloud_maintenance_notice_instance_notice',
|
|
],
|
|
'cloud_maintenance_notice_recipients' => [
|
|
'fk_cloud_maintenance_notice_recipient_notice',
|
|
],
|
|
'cloud_service_compensation_items' => [
|
|
'fk_cloud_service_compensation_item_batch',
|
|
],
|
|
'cloud_service_compensation_recipients' => [
|
|
'fk_cloud_service_compensation_recipient_batch',
|
|
],
|
|
'cloud_jobs' => ['fk_cloud_job_user'],
|
|
];
|
|
private const REQUIRED_LOG_FOREIGN_KEYS = [
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'fk_cloud_network_projection_sample',
|
|
],
|
|
];
|
|
private const REQUIRED_LOG_FOREIGN_KEY_RULES = [
|
|
'cloud_vm_network_projection_outbox' => [
|
|
'fk_cloud_network_projection_sample' => [
|
|
'delete_rule' => 'RESTRICT',
|
|
'update_rule' => 'RESTRICT',
|
|
],
|
|
],
|
|
];
|
|
|
|
public static function initialize(): bool
|
|
{
|
|
if (Config::get('enable_log', 'false') !== 'true') {
|
|
throw new \RuntimeException('请启用并配置日志数据库,虚拟机指标必须写入日志库');
|
|
}
|
|
if ((string) Config::get('db_prefix', '') !== '') {
|
|
throw new \RuntimeException('虚拟化集成使用独立表名,请将 db_prefix 留空');
|
|
}
|
|
|
|
$connection = (new User())->getConnection();
|
|
$schema = $connection->getSchemaBuilder();
|
|
if (!$schema->hasTable('user') || !$schema->hasTable('shop')) {
|
|
throw new \RuntimeException('请先在全新业务数据库导入 web/sql/ss.sql');
|
|
}
|
|
|
|
$logConnection = User::getConnectionResolver()->connection('log');
|
|
// MySQL advisory lock names are limited to 64 characters. Lock both
|
|
// schemas in a fixed order: one main database can never be installed
|
|
// concurrently with two log targets, and one shared log database can
|
|
// never receive concurrent DDL from two main installations.
|
|
$mainLockName = 'virt-cloud-main:' . substr(hash('sha256',
|
|
(string) $connection->getDatabaseName()), 0, 48);
|
|
$logLockName = 'virt-cloud-log:' . substr(hash('sha256',
|
|
(string) $logConnection->getDatabaseName()), 0, 48);
|
|
$mainLocked = false;
|
|
$logLocked = false;
|
|
try {
|
|
$locked = $connection->selectOne(
|
|
'SELECT GET_LOCK(?, 30) AS acquired', [$mainLockName]
|
|
);
|
|
$mainLocked = (int) ($locked->acquired ?? 0) === 1;
|
|
if (!$mainLocked) {
|
|
throw new \RuntimeException(
|
|
'无法取得云业务数据库初始化锁,请稍后重试'
|
|
);
|
|
}
|
|
$locked = $logConnection->selectOne(
|
|
'SELECT GET_LOCK(?, 30) AS acquired', [$logLockName]
|
|
);
|
|
$logLocked = (int) ($locked->acquired ?? 0) === 1;
|
|
if (!$logLocked) {
|
|
throw new \RuntimeException(
|
|
'无法取得云日志数据库初始化锁,请稍后重试'
|
|
);
|
|
}
|
|
$installed = self::assertFreshSchemaBoundary(
|
|
$connection, $logConnection
|
|
);
|
|
if (!$installed) {
|
|
// MySQL DDL commits implicitly. A failed first install is
|
|
// intentionally not repaired: without the final marker the
|
|
// next run rejects the partial database and requires a fresh
|
|
// one, exactly matching the no-migration deployment contract.
|
|
$connection->unprepared(self::schema('cloud.sql'));
|
|
$logConnection->unprepared(self::schema('cloud_log.sql'));
|
|
self::assertInstalledSchema($connection, $logConnection);
|
|
self::ensureMultiHostDefaults($connection);
|
|
// One atomic insert publishes both the source version and the
|
|
// exact installed information_schema signature. The version
|
|
// row is therefore never visible without its fingerprint.
|
|
$connection->table('configurations')->insert([
|
|
[
|
|
'name' => 'cloud_schema_fingerprint',
|
|
'value' => self::installedSchemaFingerprint(
|
|
$connection, $logConnection
|
|
),
|
|
],
|
|
[
|
|
'name' => 'cloud_schema_version',
|
|
'value' => self::schemaMarker(),
|
|
],
|
|
]);
|
|
} else {
|
|
self::ensureMultiHostDefaults($connection);
|
|
}
|
|
} finally {
|
|
if ($logLocked) {
|
|
$logConnection->selectOne(
|
|
'SELECT RELEASE_LOCK(?) AS released', [$logLockName]
|
|
);
|
|
}
|
|
if ($mainLocked) {
|
|
$connection->selectOne(
|
|
'SELECT RELEASE_LOCK(?) AS released', [$mainLockName]
|
|
);
|
|
}
|
|
}
|
|
|
|
echo "云业务表与 Agent 指标日志表已准备。未连接或修改任何宿主机。\n";
|
|
return true;
|
|
}
|
|
|
|
/** Seed only immutable/default control rows in an otherwise fresh schema. */
|
|
private static function ensureMultiHostDefaults($connection): void
|
|
{
|
|
$connection->table('cloud_storage_backend_catalog_mutex')
|
|
->insertOrIgnore(['id' => 1, 'updated_at' => 0]);
|
|
$connection->table('cloud_public_ip_pool_catalog_mutex')
|
|
->insertOrIgnore(['id' => 1, 'updated_at' => 0]);
|
|
$connection->table('configurations')->insertOrIgnore([
|
|
'name' => 'cloud_network_lines_enabled',
|
|
'value' => 'false',
|
|
]);
|
|
$connection->table('configurations')->insertOrIgnore([
|
|
'name' => 'cloud_vpc_enabled',
|
|
'value' => 'false',
|
|
]);
|
|
}
|
|
|
|
/** Refuse to mix the Go/Agent schema with any unmarked cloud database. */
|
|
private static function assertFreshSchemaBoundary($connection,
|
|
$logConnection): bool
|
|
{
|
|
$marker = $connection->table('configurations')
|
|
->where('name', 'cloud_schema_version')->first(['value']);
|
|
if ($marker !== null) {
|
|
if (!hash_equals(self::schemaMarker(), (string) $marker->value)) {
|
|
throw new \RuntimeException(
|
|
'虚拟化数据库版本不兼容,请使用全新数据库'
|
|
);
|
|
}
|
|
foreach (self::RETIRED_LOG_TABLES as $retiredTable) {
|
|
if ($logConnection->getSchemaBuilder()->hasTable($retiredTable)) {
|
|
throw new \RuntimeException(
|
|
'日志库包含已废弃的 Python Engine 表,请使用全新日志库'
|
|
);
|
|
}
|
|
}
|
|
self::assertInstalledSchema($connection, $logConnection);
|
|
$fingerprint = $connection->table('configurations')
|
|
->where('name', 'cloud_schema_fingerprint')->first(['value']);
|
|
$actual = self::installedSchemaFingerprint(
|
|
$connection, $logConnection
|
|
);
|
|
if ($fingerprint === null
|
|
|| !is_string($fingerprint->value)
|
|
|| preg_match('/^[a-f0-9]{64}$/D',
|
|
$fingerprint->value) !== 1
|
|
|| !hash_equals($fingerprint->value, $actual)) {
|
|
throw new \RuntimeException(
|
|
'虚拟化数据库结构已变化,请使用全新数据库'
|
|
);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
if ($connection->table('configurations')
|
|
->where('name', 'cloud_schema_fingerprint')->exists()) {
|
|
throw new \RuntimeException(
|
|
'检测到不完整的云数据库安装标记,请使用全新数据库'
|
|
);
|
|
}
|
|
|
|
foreach (self::MAIN_TABLES as $table) {
|
|
if ($connection->getSchemaBuilder()->hasTable($table)) {
|
|
throw new \RuntimeException(
|
|
'检测到未标记的旧虚拟化数据库,不支持原地升级'
|
|
);
|
|
}
|
|
}
|
|
foreach (array_merge(self::LOG_TABLES, self::RETIRED_LOG_TABLES)
|
|
as $table) {
|
|
if ($logConnection->getSchemaBuilder()->hasTable($table)) {
|
|
throw new \RuntimeException(
|
|
'检测到未标记的虚拟化日志库,不支持原地升级'
|
|
);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/** Reject a marker that points at a partial, edited or incompatible schema. */
|
|
private static function assertInstalledSchema($connection,
|
|
$logConnection): void
|
|
{
|
|
$schema = $connection->getSchemaBuilder();
|
|
foreach (self::managedMainTables() as $table) {
|
|
if (!$schema->hasTable($table)) {
|
|
throw new \RuntimeException(
|
|
'云数据库结构不完整,请使用全新数据库:' . $table
|
|
);
|
|
}
|
|
}
|
|
$logSchema = $logConnection->getSchemaBuilder();
|
|
foreach (self::LOG_TABLES as $table) {
|
|
if (!$logSchema->hasTable($table)) {
|
|
throw new \RuntimeException(
|
|
'云日志数据库结构不完整,请使用全新日志库:' . $table
|
|
);
|
|
}
|
|
}
|
|
foreach (self::REQUIRED_MAIN_COLUMNS as $table => $columns) {
|
|
foreach ($columns as $column) {
|
|
if (!$schema->hasColumn($table, $column)) {
|
|
throw new \RuntimeException(
|
|
'云数据库缺少必需字段,请使用全新数据库:'
|
|
. $table . '.' . $column
|
|
);
|
|
}
|
|
}
|
|
}
|
|
foreach (self::REQUIRED_LOG_COLUMNS as $table => $columns) {
|
|
foreach ($columns as $column) {
|
|
if (!$logSchema->hasColumn($table, $column)) {
|
|
throw new \RuntimeException(
|
|
'云日志数据库缺少必需字段,请使用全新日志库:'
|
|
. $table . '.' . $column
|
|
);
|
|
}
|
|
}
|
|
}
|
|
self::assertNamedDatabaseObjects(
|
|
$connection, 'TABLE_CONSTRAINTS', 'CONSTRAINT_NAME',
|
|
'CONSTRAINT_TYPE', 'CHECK', self::REQUIRED_CHECKS
|
|
);
|
|
self::assertNamedDatabaseObjects(
|
|
$connection, 'STATISTICS', 'INDEX_NAME', null, null,
|
|
self::REQUIRED_INDEXES
|
|
);
|
|
self::assertIndexShapes($connection, self::REQUIRED_INDEX_SHAPES);
|
|
self::assertNamedDatabaseObjects(
|
|
$connection, 'TABLE_CONSTRAINTS', 'CONSTRAINT_NAME',
|
|
'CONSTRAINT_TYPE', 'FOREIGN KEY', self::REQUIRED_FOREIGN_KEYS
|
|
);
|
|
self::assertNamedDatabaseObjects(
|
|
$logConnection, 'TABLE_CONSTRAINTS', 'CONSTRAINT_NAME',
|
|
'CONSTRAINT_TYPE', 'CHECK', self::REQUIRED_LOG_CHECKS
|
|
);
|
|
self::assertNamedDatabaseObjects(
|
|
$logConnection, 'STATISTICS', 'INDEX_NAME', null, null,
|
|
self::REQUIRED_LOG_INDEXES
|
|
);
|
|
self::assertIndexShapes(
|
|
$logConnection, self::REQUIRED_LOG_INDEX_SHAPES
|
|
);
|
|
self::assertNamedDatabaseObjects(
|
|
$logConnection, 'TABLE_CONSTRAINTS', 'CONSTRAINT_NAME',
|
|
'CONSTRAINT_TYPE', 'FOREIGN KEY', self::REQUIRED_LOG_FOREIGN_KEYS
|
|
);
|
|
self::assertForeignKeyRules(
|
|
$logConnection, self::REQUIRED_LOG_FOREIGN_KEY_RULES
|
|
);
|
|
}
|
|
|
|
private static function assertNamedDatabaseObjects($connection,
|
|
string $informationTable, string $nameColumn, ?string $typeColumn,
|
|
?string $type, array $required): void
|
|
{
|
|
$database = (string) $connection->getDatabaseName();
|
|
foreach ($required as $table => $names) {
|
|
$sql = 'SELECT DISTINCT ' . $nameColumn . ' AS object_name FROM '
|
|
. 'information_schema.' . $informationTable
|
|
. ' WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?';
|
|
$bindings = [$database, $table];
|
|
if ($typeColumn !== null && $type !== null) {
|
|
$sql .= ' AND ' . $typeColumn . ' = ?';
|
|
$bindings[] = $type;
|
|
}
|
|
$found = [];
|
|
foreach ($connection->select($sql, $bindings) as $row) {
|
|
$found[(string) ($row->object_name ?? '')] = true;
|
|
}
|
|
foreach ($names as $name) {
|
|
if (!isset($found[$name])) {
|
|
throw new \RuntimeException(
|
|
'云数据库结构校验失败,请使用全新数据库:'
|
|
. $table . '.' . $name
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static function assertIndexShapes($connection,
|
|
array $required): void
|
|
{
|
|
$database = (string) $connection->getDatabaseName();
|
|
foreach ($required as $table => $indexes) {
|
|
$rows = $connection->select(
|
|
'SELECT INDEX_NAME, NON_UNIQUE, SEQ_IN_INDEX, COLUMN_NAME '
|
|
. 'FROM information_schema.STATISTICS '
|
|
. 'WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? '
|
|
. 'ORDER BY INDEX_NAME, SEQ_IN_INDEX',
|
|
[$database, $table]
|
|
);
|
|
$found = [];
|
|
foreach ($rows as $row) {
|
|
$name = (string) ($row->INDEX_NAME
|
|
?? $row->index_name ?? '');
|
|
if ($name === '') {
|
|
continue;
|
|
}
|
|
if (!isset($found[$name])) {
|
|
$found[$name] = [
|
|
'non_unique' => (int) ($row->NON_UNIQUE
|
|
?? $row->non_unique ?? -1),
|
|
'columns' => [],
|
|
];
|
|
}
|
|
$found[$name]['columns'][] = (string) ($row->COLUMN_NAME
|
|
?? $row->column_name ?? '');
|
|
}
|
|
foreach ($indexes as $name => $shape) {
|
|
if (!isset($found[$name])
|
|
|| $found[$name]['non_unique']
|
|
!== (int) $shape['non_unique']
|
|
|| $found[$name]['columns'] !== $shape['columns']) {
|
|
throw new \RuntimeException(
|
|
'云数据库索引结构校验失败,请使用全新数据库:'
|
|
. $table . '.' . $name
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static function assertForeignKeyRules($connection,
|
|
array $required): void
|
|
{
|
|
$database = (string) $connection->getDatabaseName();
|
|
foreach ($required as $table => $constraints) {
|
|
$rows = $connection->select(
|
|
'SELECT CONSTRAINT_NAME, DELETE_RULE, UPDATE_RULE '
|
|
. 'FROM information_schema.REFERENTIAL_CONSTRAINTS '
|
|
. 'WHERE CONSTRAINT_SCHEMA = ? AND TABLE_NAME = ?',
|
|
[$database, $table]
|
|
);
|
|
$found = [];
|
|
foreach ($rows as $row) {
|
|
$name = (string) ($row->CONSTRAINT_NAME
|
|
?? $row->constraint_name ?? '');
|
|
if ($name === '') {
|
|
continue;
|
|
}
|
|
$found[$name] = [
|
|
'delete_rule' => strtoupper((string) ($row->DELETE_RULE
|
|
?? $row->delete_rule ?? '')),
|
|
'update_rule' => strtoupper((string) ($row->UPDATE_RULE
|
|
?? $row->update_rule ?? '')),
|
|
];
|
|
}
|
|
foreach ($constraints as $name => $rules) {
|
|
if (!isset($found[$name])
|
|
|| $found[$name]['delete_rule']
|
|
!== strtoupper((string) $rules['delete_rule'])
|
|
|| $found[$name]['update_rule']
|
|
!== strtoupper((string) $rules['update_rule'])) {
|
|
throw new \RuntimeException(
|
|
'云数据库外键规则校验失败,请使用全新数据库:'
|
|
. $table . '.' . $name
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private static function schemaMarker(): string
|
|
{
|
|
return self::SCHEMA_VERSION . ':' . hash('sha256',
|
|
self::schema('ss.sql') . "\0" . self::schema('cloud.sql')
|
|
. "\0" . self::schema('cloud_log.sql')
|
|
);
|
|
}
|
|
|
|
/** Hash the actual columns, indexes and constraints of both cloud schemas. */
|
|
private static function installedSchemaFingerprint($connection,
|
|
$logConnection): string
|
|
{
|
|
return hash('sha256', json_encode([
|
|
'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();
|
|
$placeholders = implode(',', array_fill(0, count($tables), '?'));
|
|
$bindings = array_merge([$database], $tables);
|
|
$queries = [
|
|
'tables' => 'SELECT TABLE_NAME, ENGINE, TABLE_COLLATION '
|
|
. 'FROM information_schema.TABLES WHERE TABLE_SCHEMA = ? '
|
|
. 'AND TABLE_NAME IN (' . $placeholders . ') '
|
|
. 'ORDER BY TABLE_NAME',
|
|
'columns' => 'SELECT TABLE_NAME, ORDINAL_POSITION, COLUMN_NAME, '
|
|
. 'COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, EXTRA, '
|
|
. 'COLLATION_NAME FROM information_schema.COLUMNS '
|
|
. 'WHERE TABLE_SCHEMA = ? AND TABLE_NAME IN ('
|
|
. $placeholders . ') ORDER BY TABLE_NAME, ORDINAL_POSITION',
|
|
'indexes' => 'SELECT TABLE_NAME, INDEX_NAME, NON_UNIQUE, '
|
|
. 'SEQ_IN_INDEX, COLUMN_NAME, SUB_PART, INDEX_TYPE '
|
|
. 'FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = ? '
|
|
. 'AND TABLE_NAME IN (' . $placeholders . ') '
|
|
. 'ORDER BY TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX',
|
|
'constraints' => 'SELECT tc.TABLE_NAME, tc.CONSTRAINT_NAME, '
|
|
. 'tc.CONSTRAINT_TYPE, cc.CHECK_CLAUSE '
|
|
. 'FROM information_schema.TABLE_CONSTRAINTS tc LEFT JOIN '
|
|
. 'information_schema.CHECK_CONSTRAINTS cc ON '
|
|
. 'cc.CONSTRAINT_SCHEMA = tc.CONSTRAINT_SCHEMA AND '
|
|
. 'cc.CONSTRAINT_NAME = tc.CONSTRAINT_NAME '
|
|
. 'WHERE tc.TABLE_SCHEMA = ? AND tc.TABLE_NAME IN ('
|
|
. $placeholders . ') ORDER BY tc.TABLE_NAME, '
|
|
. 'tc.CONSTRAINT_NAME',
|
|
'keys' => 'SELECT TABLE_NAME, CONSTRAINT_NAME, ORDINAL_POSITION, '
|
|
. 'COLUMN_NAME, REFERENCED_TABLE_NAME, '
|
|
. 'REFERENCED_COLUMN_NAME FROM '
|
|
. 'information_schema.KEY_COLUMN_USAGE '
|
|
. 'WHERE TABLE_SCHEMA = ? AND TABLE_NAME IN ('
|
|
. $placeholders . ') ORDER BY TABLE_NAME, CONSTRAINT_NAME, '
|
|
. 'ORDINAL_POSITION',
|
|
'referential' => 'SELECT TABLE_NAME, CONSTRAINT_NAME, '
|
|
. 'UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, '
|
|
. 'MATCH_OPTION, UPDATE_RULE, DELETE_RULE, '
|
|
. 'REFERENCED_TABLE_NAME FROM '
|
|
. 'information_schema.REFERENTIAL_CONSTRAINTS '
|
|
. 'WHERE CONSTRAINT_SCHEMA = ? AND TABLE_NAME IN ('
|
|
. $placeholders . ') ORDER BY TABLE_NAME, CONSTRAINT_NAME',
|
|
];
|
|
$objects = [];
|
|
foreach ($queries as $name => $sql) {
|
|
$objects[$name] = array_map(static function ($row): array {
|
|
$value = (array) $row;
|
|
ksort($value, SORT_STRING);
|
|
return $value;
|
|
}, $connection->select($sql, $bindings));
|
|
}
|
|
return $objects;
|
|
}
|
|
|
|
private static function schema(string $name): string
|
|
{
|
|
$sql = file_get_contents(BASE_PATH . '/sql/' . $name);
|
|
if ($sql === false || trim($sql) === '') {
|
|
throw new \RuntimeException('缺少虚拟化建表脚本:' . $name);
|
|
}
|
|
return $sql;
|
|
}
|
|
}
|