fix(knowledge): gate policy answers by formal sources

This commit is contained in:
key
2026-07-31 00:28:41 +08:00
parent a3689591e7
commit bf703b7853
16 changed files with 470 additions and 20 deletions
@@ -448,6 +448,17 @@ test "$knowledge_category_code_index" = '0|tenant_id,knowledge_id,code|0'
knowledge_category_collation="$(mysql "$DB" -N -B -e "SELECT table_collation FROM information_schema.tables WHERE table_schema='$DB' AND table_name='aihr_knowledge_category';")"
test "$knowledge_category_collation" = 'utf8mb4_general_ci'
formal_source_migration="$ROOT_DIR/backend/script/sql/update/aihr_20260730_formal_knowledge_source_governance_mysql8.sql"
test -f "$formal_source_migration"
mysql "$DB" < "$formal_source_migration"
mysql "$DB" < "$formal_source_migration"
formal_source_columns="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(column_name ORDER BY ordinal_position) FROM information_schema.columns WHERE table_schema='$DB' AND table_name='aihr_knowledge_source_governance' AND column_name IN ('tenant_id','source_id','attachment_id','source_doc_id','authority_type','lifecycle_status','source_version','effective_date','expires_date','applicability_scope','content_sha256','approval_basis','approved_by','approved_time');")"
test "$formal_source_columns" = 'tenant_id,source_id,attachment_id,source_doc_id,authority_type,lifecycle_status,source_version,effective_date,expires_date,applicability_scope,content_sha256,approval_basis,approved_by,approved_time'
formal_source_attachment_unique="$(mysql "$DB" -N -B -e "SELECT CONCAT(MIN(non_unique),'|',GROUP_CONCAT(column_name ORDER BY seq_in_index)) FROM information_schema.statistics WHERE table_schema='$DB' AND table_name='aihr_knowledge_source_governance' AND index_name='uk_aihr_knowledge_source_attachment';")"
test "$formal_source_attachment_unique" = '0|tenant_id,attachment_id'
formal_source_collation="$(mysql "$DB" -N -B -e "SELECT table_collation FROM information_schema.tables WHERE table_schema='$DB' AND table_name='aihr_knowledge_source_governance';")"
test "$formal_source_collation" = 'utf8mb4_general_ci'
broadcast_migration="$ROOT_DIR/backend/script/sql/update/aihr_20260722_broadcast_mysql8.sql"
test -f "$broadcast_migration"
mysql "$DB" < "$broadcast_migration"