feat(aihr): finalize practice growth and access boundaries
This commit is contained in:
@@ -119,6 +119,72 @@ mysql "$DB" < "$ROOT_DIR/backend/script/sql/update/aihr_20260715_practice_sessio
|
||||
practice_session_evidence_columns="$(mysql "$DB" -N -B -e "SELECT COUNT(*) FROM information_schema.columns WHERE table_schema='$DB' AND table_name='aihr_practice_session' AND column_name IN ('annotations_json','review_advice','incentive_point','satisfaction_score','satisfaction_comment');")"
|
||||
test "$practice_session_evidence_columns" = '5'
|
||||
|
||||
# The growth curriculum migration must be able to upgrade the compact legacy
|
||||
# practice tables used by older deployments, and be safe when applied again.
|
||||
mysql "$DB" <<'SQL'
|
||||
ALTER TABLE aihr_practice_session
|
||||
ADD COLUMN tenant_id varchar(20) DEFAULT '000000',
|
||||
ADD COLUMN mode varchar(20) DEFAULT 'mobile',
|
||||
ADD COLUMN scenario_name varchar(100) DEFAULT NULL;
|
||||
CREATE TABLE aihr_practice_scenario (
|
||||
id bigint NOT NULL AUTO_INCREMENT,
|
||||
tenant_id varchar(20) DEFAULT '000000',
|
||||
scenario_code varchar(80) NOT NULL,
|
||||
position varchar(80) DEFAULT '生活顾问',
|
||||
difficulty tinyint DEFAULT 1,
|
||||
goal varchar(1000) DEFAULT NULL,
|
||||
enabled tinyint DEFAULT 1,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_aihr_practice_scenario (tenant_id, scenario_code)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO aihr_practice_scenario (tenant_id, scenario_code, position, difficulty, goal, enabled) VALUES
|
||||
('000000', 'legacy-growth-enabled', '生活顾问', 2, 'legacy goal', 1),
|
||||
('000000', 'legacy-growth-disabled', '保安', 3, 'legacy goal', 0);
|
||||
CREATE TABLE aihr_practice_assignment (
|
||||
id bigint NOT NULL AUTO_INCREMENT,
|
||||
tenant_id varchar(20) DEFAULT '000000',
|
||||
ext_party_id varchar(100) NOT NULL,
|
||||
request_key varchar(100) DEFAULT NULL,
|
||||
source varchar(30) NOT NULL DEFAULT 'manual',
|
||||
content_hash char(64) DEFAULT NULL,
|
||||
create_time datetime DEFAULT NULL,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE=InnoDB;
|
||||
SQL
|
||||
practice_growth_migration="$ROOT_DIR/backend/script/sql/update/aihr_20260724_practice_growth_curriculum_mysql8.sql"
|
||||
test -f "$practice_growth_migration"
|
||||
mysql "$DB" < "$practice_growth_migration"
|
||||
# A high-risk item may already have completed its first review when a release
|
||||
# re-runs this idempotent migration. Its audit trail must survive for the
|
||||
# second reviewer instead of being reset to an unreviewed item.
|
||||
mysql "$DB" <<'SQL'
|
||||
UPDATE aihr_practice_scenario
|
||||
SET review_status = '待业务审核', risk_level = '高风险',
|
||||
reviewer = '首审甲', reviewer_user_id = 101, reviewed_time = '2026-07-24 10:00:00'
|
||||
WHERE scenario_code = 'legacy-growth-enabled';
|
||||
SQL
|
||||
mysql "$DB" < "$practice_growth_migration"
|
||||
practice_growth_scenario_columns="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(column_name ORDER BY column_name) FROM information_schema.columns WHERE table_schema='$DB' AND table_name='aihr_practice_scenario' AND column_name IN ('growth_level','competency_code','collaboration_positions','review_status','risk_level','curriculum_version','reviewer','reviewer_user_id','reviewed_time','second_reviewer','second_reviewer_user_id','second_reviewed_time');")"
|
||||
test "$practice_growth_scenario_columns" = 'collaboration_positions,competency_code,curriculum_version,growth_level,review_status,reviewed_time,reviewer,reviewer_user_id,risk_level,second_reviewed_time,second_reviewer,second_reviewer_user_id'
|
||||
practice_growth_session_columns="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(column_name ORDER BY column_name) FROM information_schema.columns WHERE table_schema='$DB' AND table_name='aihr_practice_session' AND column_name IN ('position_snapshot','project_type_snapshot','growth_level','competency_code','collaboration_positions','curriculum_version','growth_confirmation_level','growth_confirmed_by','growth_confirmed_time');")"
|
||||
test "$practice_growth_session_columns" = 'collaboration_positions,competency_code,curriculum_version,growth_confirmation_level,growth_confirmed_by,growth_confirmed_time,growth_level,position_snapshot,project_type_snapshot'
|
||||
practice_growth_index="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(column_name ORDER BY seq_in_index) FROM information_schema.statistics WHERE table_schema='$DB' AND table_name='aihr_practice_scenario' AND index_name='idx_aihr_practice_scenario_curriculum';")"
|
||||
test "$practice_growth_index" = 'tenant_id,position,growth_level,competency_code,review_status,enabled'
|
||||
practice_assignment_request_index="$(mysql "$DB" -N -B -e "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='$DB' AND table_name='aihr_practice_assignment' AND index_name='uk_aihr_assignment_request';")"
|
||||
test "$practice_assignment_request_index" = '0|tenant_id,request_key,ext_party_id|0'
|
||||
practice_assignment_recent_index="$(mysql "$DB" -N -B -e "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='$DB' AND table_name='aihr_practice_assignment' AND index_name='idx_aihr_assignment_recent_content';")"
|
||||
test "$practice_assignment_recent_index" = '1|tenant_id,ext_party_id,source,content_hash,create_time|0'
|
||||
mysql "$DB" -e "ALTER TABLE aihr_practice_assignment DROP INDEX uk_aihr_assignment_request, ADD INDEX uk_aihr_assignment_request (tenant_id, request_key(20), ext_party_id), DROP INDEX idx_aihr_assignment_recent_content, ADD KEY idx_aihr_assignment_recent_content (tenant_id, ext_party_id, source, content_hash);"
|
||||
mysql "$DB" < "$practice_growth_migration"
|
||||
practice_assignment_repaired_request_index="$(mysql "$DB" -N -B -e "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='$DB' AND table_name='aihr_practice_assignment' AND index_name='uk_aihr_assignment_request';")"
|
||||
test "$practice_assignment_repaired_request_index" = '0|tenant_id,request_key,ext_party_id|0'
|
||||
practice_assignment_repaired_recent_index="$(mysql "$DB" -N -B -e "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='$DB' AND table_name='aihr_practice_assignment' AND index_name='idx_aihr_assignment_recent_content';")"
|
||||
test "$practice_assignment_repaired_recent_index" = '1|tenant_id,ext_party_id,source,content_hash,create_time|0'
|
||||
practice_growth_statuses="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(CONCAT(scenario_code,':',review_status) ORDER BY scenario_code) FROM aihr_practice_scenario WHERE scenario_code LIKE 'legacy-growth-%';")"
|
||||
test "$practice_growth_statuses" = 'legacy-growth-disabled:待业务审核,legacy-growth-enabled:待业务审核'
|
||||
practice_growth_first_review="$(mysql "$DB" -N -B -e "SELECT CONCAT(COALESCE(reviewer,''),':',COALESCE(reviewer_user_id,'')) FROM aihr_practice_scenario WHERE scenario_code='legacy-growth-enabled';")"
|
||||
test "$practice_growth_first_review" = '首审甲:101'
|
||||
|
||||
mysql "$DB" < "$ROOT_DIR/backend/script/sql/update/aihr_20260714_practice_evidence_mysql8.sql"
|
||||
mysql "$DB" < "$ROOT_DIR/backend/script/sql/update/aihr_20260714_practice_evidence_mysql8.sql"
|
||||
evidence_tables="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(table_name ORDER BY table_name) FROM information_schema.tables WHERE table_schema='$DB' AND table_name IN ('aihr_practice_audio','aihr_practice_audio_upload','aihr_practice_calibration');")"
|
||||
@@ -436,4 +502,4 @@ test "$agent_run_unique" = '0|run_id'
|
||||
agent_user_index="$(mysql "$DB" -N -B -e "SELECT GROUP_CONCAT(column_name ORDER BY seq_in_index) FROM information_schema.statistics WHERE table_schema='$DB' AND table_name='aihr_agent_run' AND index_name='idx_aihr_agent_run_user';")"
|
||||
test "$agent_user_index" = 'tenant_id,user_id,create_time'
|
||||
|
||||
echo "PASS: AIHR legacy schema migrations are idempotent, including Agent run audit, knowledge-space categories, practice evidence, knowledge feedback, candidate interview review, position/SOP qualification contracts, assistant capture, work-report idempotency, broadcast publish/withdraw audit with M1 targeting defaults and target-table contracts, v1 snapshots, and trusted broadcast question context"
|
||||
echo "PASS: AIHR legacy schema migrations are idempotent, including Agent run audit, practice growth curriculum snapshots, knowledge-space categories, practice evidence, knowledge feedback, candidate interview review, position/SOP qualification contracts, assistant capture, work-report idempotency, direct feedback, broadcast publish/withdraw audit with M1 targeting and file attachment contracts, v1 snapshots, and trusted broadcast question context"
|
||||
|
||||
Reference in New Issue
Block a user