fix(tenant): 收紧双站运营提号与录单边界

This commit is contained in:
yml
2026-11-16 16:12:55 +08:00
parent 1108df195d
commit 1ce9f7aaf5
60 changed files with 1531 additions and 337 deletions
@@ -0,0 +1,35 @@
-- +goose Up
ALTER TABLE cs_manual_entries
ADD COLUMN tenant_id BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER id,
DROP KEY uk_cs_manual_entries_entry_no_group,
ADD UNIQUE KEY uk_cs_manual_entries_tenant_entry_group (tenant_id, entry_no, entry_group),
ADD KEY idx_cs_manual_entries_tenant_admin_created (tenant_id, admin_id, created_at);
UPDATE cs_manual_entries
SET tenant_id = (SELECT id FROM tenants WHERE code = 'dachui' LIMIT 1)
WHERE tenant_id = 0;
ALTER TABLE cs_manual_entry_options
ADD COLUMN tenant_id BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER id,
DROP KEY uk_cs_manual_entry_options_type_name,
ADD UNIQUE KEY uk_cs_manual_entry_options_tenant_type_name (tenant_id, type, name),
ADD KEY idx_cs_manual_entry_options_tenant_type_sort (tenant_id, type, sort_order, id);
UPDATE cs_manual_entry_options
SET tenant_id = (SELECT id FROM tenants WHERE code = 'dachui' LIMIT 1)
WHERE tenant_id = 0;
-- +goose Down
ALTER TABLE cs_manual_entry_options
DROP KEY idx_cs_manual_entry_options_tenant_type_sort,
DROP KEY uk_cs_manual_entry_options_tenant_type_name,
ADD UNIQUE KEY uk_cs_manual_entry_options_type_name (type, name),
DROP COLUMN tenant_id;
ALTER TABLE cs_manual_entries
DROP KEY idx_cs_manual_entries_tenant_admin_created,
DROP KEY uk_cs_manual_entries_tenant_entry_group,
ADD UNIQUE KEY uk_cs_manual_entries_entry_no_group (entry_no, entry_group),
DROP COLUMN tenant_id;