feat(aihr): close functional checklist gaps

This commit is contained in:
key
2026-08-02 12:15:45 +08:00
parent 699cc08050
commit 6ad8a017a4
80 changed files with 4930 additions and 430 deletions
+75 -4
View File
@@ -226,6 +226,7 @@ FROM (
UNION ALL SELECT 'aihr_onboard_exam'
UNION ALL SELECT 'aihr_onboard_exam_target'
UNION ALL SELECT 'aihr_onboard_exam_question'
UNION ALL SELECT 'aihr_exam_question_draw'
UNION ALL SELECT 'aihr_onboard_exam_attempt'
UNION ALL SELECT 'aihr_onboard_exam_answer'
UNION ALL SELECT 'aihr_web_search_provider'
@@ -508,6 +509,71 @@ REMOTE
[[ "$work_report_unique_index" = "0|tenant_id,submitter_user_id,request_key|0" ]] \
|| fail "remote work-report unique index invalid: expected unique full columns tenant_id,submitter_user_id,request_key; got ${work_report_unique_index:-missing}"
local feedback_question_bridge_contract
feedback_question_bridge_contract="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
db="$1"
mysql --batch --skip-column-names --connect-timeout=5 "$db" <<'SQL'
SELECT CONCAT(
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'aihr_knowledge_answer_feedback'
AND column_name IN ('submitter_user_id','request_id')), '|',
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'aihr_community_question'
AND column_name IN ('source_type','source_request_id','submit_idempotency_key')), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_knowledge_answer_feedback'
AND index_name = 'uk_aihr_answer_feedback_user_request'), ''), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_community_question'
AND index_name = 'uk_aihr_community_question_source'), ''), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_community_question'
AND index_name = 'uk_aihr_community_question_submit_key'), '')
);
SQL
REMOTE
)" || fail "remote feedback-question bridge schema check failed: $remote_ssh:$remote_db"
[[ "$feedback_question_bridge_contract" = "2|3|0:tenant_id,submitter_user_id,request_id,fragment_id:0|0:tenant_id,author_user_id,source_type,source_request_id:0|0:tenant_id,author_user_id,submit_idempotency_key:0" ]] \
|| fail "remote feedback-question bridge contract invalid: got ${feedback_question_bridge_contract:-missing}"
local learning_task_exam_bank_contract
learning_task_exam_bank_contract="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
db="$1"
mysql --batch --skip-column-names --connect-timeout=5 "$db" <<'SQL'
SELECT CONCAT(
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'aihr_learning_question'
AND column_name IN ('exam_format','exam_options_json','exam_answers_json','exam_explanation','exam_enabled','review_status','review_note','reviewed_by','reviewed_time')), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_learning_question'
AND index_name = 'idx_aihr_learning_question_exam_pick'), ''), '|',
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'aihr_onboard_exam_question'
AND column_name IN ('source_question_id','source_question_code','source_content_version','source_content_hash')), '|',
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = 'aihr_onboard_task'
AND column_name IN ('material_type','material_attachment_id','material_title','material_version','progress_percent','completion_rule','exam_id','recurrence_type','recurrence_series_key','dispatch_request_key')), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_onboard_task'
AND index_name = 'uk_aihr_onboard_task_dispatch'), ''), '|',
COALESCE((SELECT CONCAT(MIN(non_unique), ':', GROUP_CONCAT(column_name ORDER BY seq_in_index), ':', SUM(sub_part IS NOT NULL))
FROM information_schema.statistics
WHERE table_schema = DATABASE() AND table_name = 'aihr_exam_question_draw'
AND index_name = 'uk_aihr_exam_question_draw_request'), '')
);
SQL
REMOTE
)" || fail "remote learning-task/question-bank schema check failed: $remote_ssh:$remote_db"
[[ "$learning_task_exam_bank_contract" = "9|1:tenant_id,position_code,review_status,exam_enabled,enabled,id:0|4|10|0:tenant_id,ext_party_id,dispatch_request_key:0|0:tenant_id,owner_ext_party_id,request_key:0" ]] \
|| fail "remote learning-task/question-bank contract invalid: got ${learning_task_exam_bank_contract:-missing}"
local missing_broadcast_publish_columns
missing_broadcast_publish_columns="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
@@ -719,7 +785,7 @@ SELECT CONCAT(
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'aihr_broadcast_message'
AND column_name = 'attachment_id'),
AND column_name IN ('attachment_id','visibility_mode','allow_download')),
'|',
COALESCE((SELECT GROUP_CONCAT(column_name ORDER BY seq_in_index)
FROM information_schema.statistics
@@ -731,14 +797,18 @@ SELECT CONCAT(
FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'aihr_broadcast_attachment'
AND index_name = 'idx_aihr_broadcast_attachment_insight_queue'), '')
AND index_name = 'idx_aihr_broadcast_attachment_insight_queue'), ''),
'|',
(SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name IN ('aihr_broadcast_attachment_topic_tag','aihr_broadcast_attachment_access_audit'))
);
SQL
REMOTE
)" || fail "remote broadcast-attachment schema check failed: $remote_ssh:$remote_db"
[[ "$broadcast_attachment_contract" = "14|1|tenant_id,attachment_id|insight_status,status,update_time" ]] \
|| fail "remote broadcast-attachment contract invalid: expected 14 attachment columns, indexed message attachment_id, and insight queue index; got ${broadcast_attachment_contract:-missing}"
[[ "$broadcast_attachment_contract" = "14|3|tenant_id,attachment_id|insight_status,status,update_time|2" ]] \
|| fail "remote broadcast-attachment contract invalid: expected attachment columns, delivery controls, topic/access tables, and required indexes; got ${broadcast_attachment_contract:-missing}"
local missing_work_assistant_columns
missing_work_assistant_columns="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
@@ -798,6 +868,7 @@ REMOTE
echo "remote_schema=64/64 $remote_ssh:$remote_db"
echo "remote_media_reprocess_contract=1/1 $remote_ssh:$remote_db"
echo "remote_work_report_idempotency=3/3 $remote_ssh:$remote_db"
echo "remote_learning_task_question_bank=6/6 $remote_ssh:$remote_db"
echo "remote_practice_curriculum_columns=13/13 $remote_ssh:$remote_db"
echo "remote_knowledge_category_columns=7/7 $remote_ssh:$remote_db"
echo "remote_broadcast_publish_audit_columns=3/3 $remote_ssh:$remote_db"