在前后端开发联调前 的提交20260223

This commit is contained in:
Neo
2026-02-23 23:02:20 +08:00
parent 254ccb1e77
commit fafc95e64c
1142 changed files with 10366960 additions and 36957 deletions

View File

@@ -1,97 +0,0 @@
-- 迁移脚本:为 ODS 表添加"取最新版本"复合索引
-- 支持 DISTINCT ON (pk) ORDER BY pk, fetched_at DESC 查询模式
-- 注意CREATE INDEX CONCURRENTLY 不能在事务块内执行,需逐条手动运行或用支持单语句模式的工具
-- 日期2026-02-17
-- 关联需求ods-dedup-standardize Requirements 6.1, 6.2, 6.3
-- 1. assistant_accounts_master (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_assistant_accounts_master_latest
ON ods.assistant_accounts_master (id, fetched_at DESC);
-- 2. settlement_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_settlement_records_latest
ON ods.settlement_records (id, fetched_at DESC);
-- 3. table_fee_transactions (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_table_fee_transactions_latest
ON ods.table_fee_transactions (id, fetched_at DESC);
-- 4. assistant_service_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_assistant_service_records_latest
ON ods.assistant_service_records (id, fetched_at DESC);
-- 5. assistant_cancellation_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_assistant_cancellation_records_latest
ON ods.assistant_cancellation_records (id, fetched_at DESC);
-- 6. store_goods_sales_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_store_goods_sales_records_latest
ON ods.store_goods_sales_records (id, fetched_at DESC);
-- 7. payment_transactions (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_payment_transactions_latest
ON ods.payment_transactions (id, fetched_at DESC);
-- 8. refund_transactions (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_refund_transactions_latest
ON ods.refund_transactions (id, fetched_at DESC);
-- 9. platform_coupon_redemption_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_platform_coupon_redemption_records_latest
ON ods.platform_coupon_redemption_records (id, fetched_at DESC);
-- 10. member_profiles (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_member_profiles_latest
ON ods.member_profiles (id, fetched_at DESC);
-- 11. member_stored_value_cards (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_member_stored_value_cards_latest
ON ods.member_stored_value_cards (id, fetched_at DESC);
-- 12. member_balance_changes (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_member_balance_changes_latest
ON ods.member_balance_changes (id, fetched_at DESC);
-- 13. recharge_settlements (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_recharge_settlements_latest
ON ods.recharge_settlements (id, fetched_at DESC);
-- 14. group_buy_packages (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_group_buy_packages_latest
ON ods.group_buy_packages (id, fetched_at DESC);
-- 15. group_buy_redemption_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_group_buy_redemption_records_latest
ON ods.group_buy_redemption_records (id, fetched_at DESC);
-- 16. goods_stock_summary (pk: siteGoodsId)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_goods_stock_summary_latest
ON ods.goods_stock_summary (siteGoodsId, fetched_at DESC);
-- 17. goods_stock_movements (pk: siteGoodsStockId)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_goods_stock_movements_latest
ON ods.goods_stock_movements (siteGoodsStockId, fetched_at DESC);
-- 18. site_tables_master (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_site_tables_master_latest
ON ods.site_tables_master (id, fetched_at DESC);
-- 19. stock_goods_category_tree (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_stock_goods_category_tree_latest
ON ods.stock_goods_category_tree (id, fetched_at DESC);
-- 20. store_goods_master (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_store_goods_master_latest
ON ods.store_goods_master (id, fetched_at DESC);
-- 21. table_fee_discount_records (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_table_fee_discount_records_latest
ON ods.table_fee_discount_records (id, fetched_at DESC);
-- 22. tenant_goods_master (pk: id)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_tenant_goods_master_latest
ON ods.tenant_goods_master (id, fetched_at DESC);
-- 23. settlement_ticket_details (pk: orderSettleId)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_ods_settlement_ticket_details_latest
ON ods.settlement_ticket_details (orderSettleId, fetched_at DESC);

View File

@@ -0,0 +1,139 @@
-- =============================================================================
-- 迁移脚本:创建员工档案 ODS + DWD 表
-- 日期2026-02-22
-- 说明:从 SearchSystemStaffInfo API 抓取员工数据ODS 落地后清洗至 DWD 维度表
-- 需求US-1, US-2, US-3
-- =============================================================================
-- ---------------------------------------------------------------------------
-- 1. ODS 层ods.staff_info_master
-- ---------------------------------------------------------------------------
CREATE TABLE ods.staff_info_master (
id BIGINT NOT NULL,
tenant_id BIGINT,
site_id BIGINT,
tenant_org_id BIGINT,
system_user_id BIGINT,
staff_name TEXT,
alias_name TEXT,
mobile TEXT,
avatar TEXT,
gender INTEGER,
job TEXT,
job_num TEXT,
staff_identity INTEGER,
status INTEGER,
account_status INTEGER,
system_role_id INTEGER,
rank_id INTEGER,
rank_name TEXT,
new_rank_id INTEGER,
new_staff_identity INTEGER,
leave_status INTEGER,
entry_time TIMESTAMP WITHOUT TIME ZONE,
resign_time TIMESTAMP WITHOUT TIME ZONE,
create_time TIMESTAMP WITHOUT TIME ZONE,
is_delete INTEGER,
is_reserve INTEGER,
shop_name TEXT,
site_label TEXT,
cashier_point_id BIGINT,
cashier_point_name TEXT,
group_id BIGINT,
group_name TEXT,
staff_profile_id BIGINT,
auth_code TEXT,
auth_code_create TIMESTAMP WITHOUT TIME ZONE,
ding_talk_synced INTEGER,
salary_grant_enabled INTEGER,
entry_type INTEGER,
entry_sign_status INTEGER,
resign_sign_status INTEGER,
criticism_status INTEGER,
user_roles JSONB,
-- ETL 元数据
content_hash TEXT NOT NULL,
source_file TEXT,
fetched_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
payload JSONB NOT NULL
);
COMMENT ON TABLE ods.staff_info_master IS '员工档案主数据来源SearchSystemStaffInfo API';
-- ---------------------------------------------------------------------------
-- 2. DWD 层dwd.dim_staff主表核心业务字段SCD2
-- ---------------------------------------------------------------------------
CREATE TABLE dwd.dim_staff (
staff_id BIGINT NOT NULL,
staff_name TEXT,
alias_name TEXT,
mobile TEXT,
gender INTEGER,
job TEXT,
tenant_id BIGINT,
site_id BIGINT,
system_role_id INTEGER,
staff_identity INTEGER,
status INTEGER,
leave_status INTEGER,
entry_time TIMESTAMP WITH TIME ZONE,
resign_time TIMESTAMP WITH TIME ZONE,
is_delete INTEGER,
-- SCD2
scd2_start_time TIMESTAMP WITH TIME ZONE NOT NULL,
scd2_end_time TIMESTAMP WITH TIME ZONE,
scd2_is_current INTEGER,
scd2_version INTEGER,
PRIMARY KEY (staff_id, scd2_start_time)
);
COMMENT ON TABLE dwd.dim_staff IS '员工档案维度主表SCD2';
-- ---------------------------------------------------------------------------
-- 3. DWD 层dwd.dim_staff_ex扩展表次要/低频变更字段SCD2
-- ---------------------------------------------------------------------------
CREATE TABLE dwd.dim_staff_ex (
staff_id BIGINT NOT NULL,
avatar TEXT,
job_num TEXT,
account_status INTEGER,
rank_id INTEGER,
rank_name TEXT,
new_rank_id INTEGER,
new_staff_identity INTEGER,
is_reserve INTEGER,
shop_name TEXT,
site_label TEXT,
tenant_org_id BIGINT,
system_user_id BIGINT,
cashier_point_id BIGINT,
cashier_point_name TEXT,
group_id BIGINT,
group_name TEXT,
staff_profile_id BIGINT,
auth_code TEXT,
auth_code_create TIMESTAMP WITH TIME ZONE,
ding_talk_synced INTEGER,
salary_grant_enabled INTEGER,
entry_type INTEGER,
entry_sign_status INTEGER,
resign_sign_status INTEGER,
criticism_status INTEGER,
create_time TIMESTAMP WITH TIME ZONE,
user_roles JSONB,
-- SCD2
scd2_start_time TIMESTAMP WITH TIME ZONE NOT NULL,
scd2_end_time TIMESTAMP WITH TIME ZONE,
scd2_is_current INTEGER,
scd2_version INTEGER,
PRIMARY KEY (staff_id, scd2_start_time)
);
COMMENT ON TABLE dwd.dim_staff_ex IS '员工档案维度扩展表SCD2';
-- =============================================================================
-- 回滚脚本(如需撤销)
-- DROP TABLE IF EXISTS dwd.dim_staff_ex;
-- DROP TABLE IF EXISTS dwd.dim_staff;
-- DROP TABLE IF EXISTS ods.staff_info_master;
-- =============================================================================

View File

@@ -0,0 +1,70 @@
-- =============================================================================
-- 迁移脚本:创建 dws.dws_member_spending_power_index 表
-- 日期2026-02-23
-- 说明SPI消费力指数结果表存储会员级消费力评分及中间特征
-- 需求1.1, 1.2, 1.3, 1.4, 1.5
-- =============================================================================
-- 序列BIGSERIAL 自动创建,此处显式声明以保持与项目风格一致)
CREATE SEQUENCE IF NOT EXISTS dws.dws_member_spending_power_index_spi_id_seq AS bigint;
-- 主表
CREATE TABLE dws.dws_member_spending_power_index (
spi_id BIGINT DEFAULT nextval('dws.dws_member_spending_power_index_spi_id_seq'::regclass) NOT NULL,
site_id INTEGER NOT NULL,
member_id BIGINT NOT NULL,
-- 基础特征
spend_30 NUMERIC(14,2) DEFAULT 0, -- 近30天消费总额
spend_90 NUMERIC(14,2) DEFAULT 0, -- 近90天消费总额
recharge_90 NUMERIC(14,2) DEFAULT 0, -- 近90天充值总额
orders_30 INTEGER DEFAULT 0, -- 近30天消费笔数
orders_90 INTEGER DEFAULT 0, -- 近90天消费笔数
visit_days_30 INTEGER DEFAULT 0, -- 近30天消费日数按天去重
visit_days_90 INTEGER DEFAULT 0, -- 近90天消费日数按天去重
avg_ticket_90 NUMERIC(14,2) DEFAULT 0, -- 90天客单价
active_weeks_90 INTEGER DEFAULT 0, -- 近90天有消费的自然周数最多13
daily_spend_ewma_90 NUMERIC(14,2) DEFAULT 0, -- 日消费 EWMA
-- 子分Raw算法直接计算的未归一化分数
score_level_raw NUMERIC(10,4) DEFAULT 0, -- Level 子分原始分
score_speed_raw NUMERIC(10,4) DEFAULT 0, -- Speed 子分原始分
score_stability_raw NUMERIC(10,4) DEFAULT 0, -- Stability 子分原始分
-- 子分Display归一化到 0-10 的展示分)
score_level_display NUMERIC(5,2) DEFAULT 0,
score_speed_display NUMERIC(5,2) DEFAULT 0,
score_stability_display NUMERIC(5,2) DEFAULT 0,
-- 总分
raw_score NUMERIC(10,4) DEFAULT 0, -- SPI 原始分(加权合成)
display_score NUMERIC(5,2) DEFAULT 0, -- SPI 展示分0-10
-- 元数据
calc_time TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
-- 主键
CONSTRAINT dws_member_spending_power_index_pkey PRIMARY KEY (spi_id)
);
-- 唯一约束(业务主键:一个门店一个会员只有一条记录)
CREATE UNIQUE INDEX idx_spi_site_member
ON dws.dws_member_spending_power_index (site_id, member_id);
-- 查询索引(按门店查询展示分排名)
CREATE INDEX idx_spi_display_score
ON dws.dws_member_spending_power_index (site_id, display_score DESC);
-- 序列归属
ALTER SEQUENCE dws.dws_member_spending_power_index_spi_id_seq
OWNED BY dws.dws_member_spending_power_index.spi_id;
-- =============================================================================
-- 回滚脚本(如需撤销)
-- DROP INDEX IF EXISTS dws.idx_spi_display_score;
-- DROP INDEX IF EXISTS dws.idx_spi_site_member;
-- DROP TABLE IF EXISTS dws.dws_member_spending_power_index;
-- DROP SEQUENCE IF EXISTS dws.dws_member_spending_power_index_spi_id_seq;
-- =============================================================================

View File

@@ -1,144 +0,0 @@
-- =============================================================================
-- 关系指数与 ML 人工台账迁移脚本
-- 版本: 2026-02-08
-- AI_CHANGELOG [2026-02-13] 移除 INSERT 中的 source_mode 参数ML 仅用人工台账)
-- 说明:
-- 1) 新增关系指数结果表 dws_member_assistant_relation_index
-- 2) 新增 ML 人工台账宽表/窄表
-- 3) 补充 RS/OS/MS/ML 参数并下线 INTIMACY
-- =============================================================================
BEGIN;
-- -----------------------------------------------------------------------------
-- 1) 关系指数结果表
-- -----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS billiards_dws.dws_member_assistant_relation_index (
relation_id BIGSERIAL PRIMARY KEY,
site_id BIGINT NOT NULL,
tenant_id BIGINT NOT NULL,
member_id BIGINT NOT NULL,
assistant_id BIGINT NOT NULL,
session_count INTEGER NOT NULL DEFAULT 0,
total_duration_minutes INTEGER NOT NULL DEFAULT 0,
basic_session_count INTEGER NOT NULL DEFAULT 0,
incentive_session_count INTEGER NOT NULL DEFAULT 0,
days_since_last_session INTEGER,
rs_f NUMERIC(14,6) NOT NULL DEFAULT 0,
rs_d NUMERIC(14,6) NOT NULL DEFAULT 0,
rs_r NUMERIC(14,6) NOT NULL DEFAULT 0,
rs_raw NUMERIC(14,6) NOT NULL DEFAULT 0,
rs_display NUMERIC(4,2) NOT NULL DEFAULT 0,
os_share NUMERIC(10,6) NOT NULL DEFAULT 0,
os_label VARCHAR(20) NOT NULL DEFAULT 'POOL',
os_rank INTEGER,
ms_f_short NUMERIC(14,6) NOT NULL DEFAULT 0,
ms_f_long NUMERIC(14,6) NOT NULL DEFAULT 0,
ms_raw NUMERIC(14,6) NOT NULL DEFAULT 0,
ms_display NUMERIC(4,2) NOT NULL DEFAULT 0,
ml_order_count INTEGER NOT NULL DEFAULT 0,
ml_allocated_amount NUMERIC(14,2) NOT NULL DEFAULT 0,
ml_raw NUMERIC(14,6) NOT NULL DEFAULT 0,
ml_display NUMERIC(4,2) NOT NULL DEFAULT 0,
calc_time TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT uk_dws_member_assistant_relation_index UNIQUE (site_id, member_id, assistant_id)
);
CREATE INDEX IF NOT EXISTS idx_dws_relation_member
ON billiards_dws.dws_member_assistant_relation_index (site_id, member_id, os_share DESC);
CREATE INDEX IF NOT EXISTS idx_dws_relation_assistant
ON billiards_dws.dws_member_assistant_relation_index (site_id, assistant_id, rs_display DESC);
CREATE INDEX IF NOT EXISTS idx_dws_relation_calc_time
ON billiards_dws.dws_member_assistant_relation_index (calc_time);
-- -----------------------------------------------------------------------------
-- 2) ML 人工台账宽表
-- -----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS billiards_dws.dws_ml_manual_order_source (
source_id BIGSERIAL PRIMARY KEY,
site_id BIGINT NOT NULL,
biz_date DATE NOT NULL,
external_id VARCHAR(128) NOT NULL,
member_id BIGINT NOT NULL DEFAULT 0,
pay_time TIMESTAMPTZ NOT NULL,
order_amount NUMERIC(14,2) NOT NULL DEFAULT 0,
currency VARCHAR(16) NOT NULL DEFAULT 'CNY',
assistant_id_1 BIGINT,
assistant_name_1 VARCHAR(128),
assistant_id_2 BIGINT,
assistant_name_2 VARCHAR(128),
assistant_id_3 BIGINT,
assistant_name_3 VARCHAR(128),
assistant_id_4 BIGINT,
assistant_name_4 VARCHAR(128),
assistant_id_5 BIGINT,
assistant_name_5 VARCHAR(128),
import_batch_no VARCHAR(64) NOT NULL,
import_file_name VARCHAR(255) NOT NULL,
import_scope_key VARCHAR(128) NOT NULL,
import_time TIMESTAMPTZ NOT NULL DEFAULT NOW(),
import_user VARCHAR(64),
row_no INTEGER NOT NULL,
remark TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT uk_dws_ml_manual_order_source UNIQUE (site_id, external_id, import_scope_key, row_no)
);
CREATE INDEX IF NOT EXISTS idx_dws_ml_source_scope
ON billiards_dws.dws_ml_manual_order_source (site_id, biz_date);
CREATE INDEX IF NOT EXISTS idx_dws_ml_source_external
ON billiards_dws.dws_ml_manual_order_source (site_id, external_id);
-- -----------------------------------------------------------------------------
-- 3) ML 人工台账窄表
-- -----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS billiards_dws.dws_ml_manual_order_alloc (
alloc_id BIGSERIAL PRIMARY KEY,
site_id BIGINT NOT NULL,
biz_date DATE NOT NULL,
external_id VARCHAR(128) NOT NULL,
member_id BIGINT NOT NULL DEFAULT 0,
pay_time TIMESTAMPTZ NOT NULL,
order_amount NUMERIC(14,2) NOT NULL DEFAULT 0,
assistant_id BIGINT NOT NULL,
assistant_name VARCHAR(128),
share_ratio NUMERIC(14,8) NOT NULL DEFAULT 0,
allocated_amount NUMERIC(14,2) NOT NULL DEFAULT 0,
currency VARCHAR(16) NOT NULL DEFAULT 'CNY',
import_scope_key VARCHAR(128) NOT NULL,
import_batch_no VARCHAR(64) NOT NULL,
import_file_name VARCHAR(255) NOT NULL,
import_time TIMESTAMPTZ NOT NULL DEFAULT NOW(),
import_user VARCHAR(64),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT uk_dws_ml_manual_order_alloc UNIQUE (site_id, external_id, assistant_id)
);
CREATE INDEX IF NOT EXISTS idx_dws_ml_alloc_scope
ON billiards_dws.dws_ml_manual_order_alloc (site_id, biz_date);
CREATE INDEX IF NOT EXISTS idx_dws_ml_alloc_member_assistant
ON billiards_dws.dws_ml_manual_order_alloc (site_id, member_id, assistant_id);
-- -----------------------------------------------------------------------------
-- 4) 参数切换
-- -----------------------------------------------------------------------------
UPDATE billiards_dws.cfg_index_parameters
SET effective_to = DATE '2025-12-31',
updated_at = NOW()
WHERE index_type = 'INTIMACY'
AND (effective_to IS NULL OR effective_to > DATE '2025-12-31');
INSERT INTO billiards_dws.cfg_index_parameters
(index_type, param_name, param_value, description, effective_from)
VALUES
('OS', 'ownership_gap_threshold', 0.150000, '主责与次席份额差阈值', DATE '2026-01-01')
ON CONFLICT (index_type, param_name, effective_from) DO UPDATE SET
param_value = EXCLUDED.param_value,
description = EXCLUDED.description,
updated_at = NOW();
COMMIT;

View File

@@ -1,14 +0,0 @@
-- ============================================================
-- ODS 表与 API JSON 字段对齐迁移
-- 自动生成于 2026-02-13
-- 基于: docs/api-reference/ 文档 vs billiards_ods 实际表结构
-- 比对逻辑: camelCase → snake_case 归一化后再比较
-- ============================================================
--
-- 结论: 22 张 ODS 表全部与 API JSON 字段对齐,无需任何 ALTER 操作。
--
-- stock_goods_category_tree 的 goodsCategoryList/total 为响应包装层字段,
-- ODS 表已正确展开存储数组内的记录级字段id, category_name, pid 等),
-- 不需要将包装层字段作为列添加。
--
-- 无需执行此文件。

View File

@@ -1,72 +0,0 @@
-- =============================================================================
-- 迁移移除旧版指数RECALL / INTIMACY及 ML last-touch 备用参数
-- 日期: 2026-02-13
-- AI_CHANGELOG [2026-02-13] 新建迁移DROP recall/intimacy 表DELETE 旧版参数/分位点/调度任务
-- 原因: 旧版 RecallIndexTask / IntimacyIndexTask 已被 WBI+NCI / RelationIndexTask 替代
-- ML 仅使用人工台账,不再需要 last-touch 备用路径
-- =============================================================================
BEGIN;
-- 1. 删除旧版指数参数
DELETE FROM billiards_dws.cfg_index_parameters
WHERE index_type IN ('RECALL', 'INTIMACY');
-- 2. 删除 ML 已废弃参数
DELETE FROM billiards_dws.cfg_index_parameters
WHERE index_type = 'ML'
AND param_name IN ('source_mode', 'recharge_attribute_hours');
-- 3. 删除旧版指数分位点历史
DELETE FROM billiards_dws.cfg_index_percentile_history
WHERE index_type IN ('RECALL', 'INTIMACY');
-- 4. 删除调度器中的旧版任务
DELETE FROM etl_admin.etl_task
WHERE task_code IN ('DWS_RECALL_INDEX', 'DWS_INTIMACY_INDEX');
-- 5. 删除旧版 recall 表(数据已由 WBI+NCI 替代)
DROP TABLE IF EXISTS billiards_dws.dws_member_recall_index CASCADE;
-- 6. 删除旧版 intimacy 表(数据已由 RelationIndexTask 替代)
DROP TABLE IF EXISTS billiards_dws.dws_member_assistant_intimacy CASCADE;
COMMIT;
-- =============================================================================
-- 验证
-- =============================================================================
DO $
DECLARE
recall_params INTEGER;
intimacy_params INTEGER;
ml_legacy INTEGER;
recall_table BOOLEAN;
intimacy_table BOOLEAN;
BEGIN
SELECT COUNT(*) INTO recall_params
FROM billiards_dws.cfg_index_parameters WHERE index_type = 'RECALL';
SELECT COUNT(*) INTO intimacy_params
FROM billiards_dws.cfg_index_parameters WHERE index_type = 'INTIMACY';
SELECT COUNT(*) INTO ml_legacy
FROM billiards_dws.cfg_index_parameters
WHERE index_type = 'ML' AND param_name IN ('source_mode', 'recharge_attribute_hours');
SELECT EXISTS(
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'billiards_dws' AND table_name = 'dws_member_recall_index'
) INTO recall_table;
SELECT EXISTS(
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'billiards_dws' AND table_name = 'dws_member_assistant_intimacy'
) INTO intimacy_table;
RAISE NOTICE 'RECALL 参数残留: % (应为 0)', recall_params;
RAISE NOTICE 'INTIMACY 参数残留: % (应为 0)', intimacy_params;
RAISE NOTICE 'ML 废弃参数残留: % (应为 0)', ml_legacy;
RAISE NOTICE 'recall 表存在: % (应为 false)', recall_table;
RAISE NOTICE 'intimacy 表存在: % (应为 false)', intimacy_table;
END $;

View File

@@ -1,12 +0,0 @@
-- 迁移:删除 DWD 层 dwd_settlement_head_ex 的 settle_list 列
-- 原因settle_list 存储结算明细 JSON与 ODS 层 payload 中的 settleList 完全重复
-- ODS 层 settlelist 列已在 20260214_drop_ods_settlelist.sql 中删除
-- DWD 层该列同样冗余,结算明细可随时从 ODS payload 提取
-- 回滚ALTER TABLE billiards_dwd.dwd_settlement_head_ex ADD COLUMN settle_list JSONB;
-- UPDATE billiards_dwd.dwd_settlement_head_ex e
-- SET settle_list = o.payload->'settleList'
-- FROM billiards_ods.settlement_records o
-- WHERE e.order_settle_id = o.id;
-- Prompt: P20260214-040000
ALTER TABLE billiards_dwd.dwd_settlement_head_ex DROP COLUMN IF EXISTS settle_list;

View File

@@ -1,23 +0,0 @@
-- 迁移:删除 ODS 层两个冗余列
-- 日期2026-02-14
-- Prompt-IDP20260214-070000
-- 原因option_namestore_goods_sales_records和 able_site_transfermember_stored_value_cards
-- 在 API JSON 响应中不存在ODS 中全部为 NULL0 条非空数据),属于冗余列
-- 回滚ALTER TABLE billiards_ods.store_goods_sales_records ADD COLUMN option_name TEXT;
-- ALTER TABLE billiards_ods.member_stored_value_cards ADD COLUMN able_site_transfer INTEGER;
-- CHANGE: intent=删除 API 中不存在的冗余 ODS 列; assumptions=两列全 NULL 无数据丢失风险; Prompt=P20260214-070000
BEGIN;
ALTER TABLE billiards_ods.store_goods_sales_records DROP COLUMN IF EXISTS option_name;
ALTER TABLE billiards_ods.member_stored_value_cards DROP COLUMN IF EXISTS able_site_transfer;
COMMIT;
-- AI_CHANGELOG:
-- - 日期: 2026-02-14
-- - Prompt: P20260214-070000 — ODS 清理与文档标注5 项任务)
-- - 直接原因: option_name 和 able_site_transfer 在 API JSON 中不存在ODS 全 NULL需删除冗余列
-- - 变更摘要: 新建迁移脚本DROP COLUMN 两张表各一列
-- - 风险与验证: 已执行成功验证information_schema 查询确认列不存在

View File

@@ -1,34 +0,0 @@
-- 迁移:删除 ODS 层 settlement_records / recharge_settlements 的 settlelist jsonb 列
-- 原因settlelist 与 payload 列数据重复payload 存储完整 API 响应 JSON已包含 settleList 对象)
-- 日期2026-02-14
-- Prompt-ID: P20260214-023000
--
-- 前置条件:确认 DWD 加载逻辑已修改为从 payload 提取 settleList而非直接读 settlelist 列)
-- 回滚:见文件末尾 ROLLBACK 部分
-- CHANGE: intent=删除冗余 settlelist 列,减少存储浪费
-- assumptions=payload 列已包含完整 settleList 数据DWD 加载已改为从 payload 提取
-- edge_cases=历史数据中 payload 为 NULL 的行将丢失 settleList 信息
-- prompt=P20260214-023000
-- 1) settlement_records
ALTER TABLE billiards_ods.settlement_records DROP COLUMN IF EXISTS settlelist;
-- 2) recharge_settlements
ALTER TABLE billiards_ods.recharge_settlements DROP COLUMN IF EXISTS settlelist;
-- 验证 SQL
-- SELECT column_name FROM information_schema.columns
-- WHERE table_schema = 'billiards_ods'
-- AND table_name IN ('settlement_records', 'recharge_settlements')
-- AND column_name = 'settlelist';
-- 预期结果0 行
-- ============================================================
-- ROLLBACK回滚
-- ============================================================
-- ALTER TABLE billiards_ods.settlement_records ADD COLUMN settlelist jsonb;
-- ALTER TABLE billiards_ods.recharge_settlements ADD COLUMN settlelist jsonb;
-- 注意:回滚后列数据为 NULL需从 payload 中重新提取:
-- UPDATE billiards_ods.settlement_records SET settlelist = payload->'settleList' WHERE payload IS NOT NULL;
-- UPDATE billiards_ods.recharge_settlements SET settlelist = payload->'settleList' WHERE payload IS NOT NULL;