Files

35 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
. "$SCRIPT_DIR/verify_common.sh"
echo "=== Phase 1 验收检查 ==="
check_file "db/migrations/001_phase1_core_tables.sql" "核心三表迁移文件存在"
check_file "db/migrations/002_sprint1_complete_schema.sql" "Sprint 1 扩展迁移文件存在"
check_sql_int_eq "Sprint 1 扩展表全部存在" \
"select count(*) from pg_tables where schemaname='public' and tablename in ('model_provider','operator','region_pricing','pricing_history','free_tier','daily_report','user_subscription','audit_log');" \
8
check_sql_int_eq "models 扩展字段已落库" \
"select count(*) from information_schema.columns where table_name='models' and column_name in ('provider_id','modality','batch_id','data_confidence');" \
4
check_sql_int_eq "关键 CHECK 约束存在" \
"select count(*) from pg_constraint where conname in ('chk_price_non_negative','chk_currency_valid','chk_models_context_length','chk_models_modality','chk_models_data_confidence');" \
5
check_sql_int_eq "updated_at 触发器已挂载到业务表" \
"select count(*) from pg_trigger where tgname in ('models_updated_at','model_provider_updated_at','operator_updated_at','region_pricing_updated_at','pricing_history_updated_at','free_tier_updated_at','daily_report_updated_at','user_subscription_updated_at');" \
8
check_sql_int_ge "厂商种子数据不少于 6 条" \
"select count(*) from model_provider;" \
6
check_sql_int_ge "region_pricing 已有迁移数据" \
"select count(*) from region_pricing;" \
1
check_sql_int_eq "血缘字段 batch_id 已完成回填" \
"select count(*) from models where batch_id is null;" \
0
finish_phase