feat: add query observability and collation safeguards
This commit is contained in:
@@ -22,6 +22,9 @@ trap cleanup EXIT
|
||||
mysql -e "CREATE DATABASE \`$DB\` CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;"
|
||||
mysql "$DB" <<'SQL'
|
||||
CREATE TABLE aihr_knowledge_info (tenant_id varchar(20) COLLATE utf8mb4_general_ci) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_knowledge_fragment (tenant_id varchar(20) COLLATE utf8mb4_general_ci, content text COLLATE utf8mb4_general_ci) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_data_asset (tenant_id varchar(20) COLLATE utf8mb4_0900_ai_ci, source_name varchar(100) COLLATE utf8mb4_0900_ai_ci) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_chunk_revision (tenant_id varchar(20) COLLATE utf8mb4_0900_ai_ci, content text COLLATE utf8mb4_0900_ai_ci) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_knowledge_space_grant (tenant_id varchar(20), label varchar(20)) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_knowledge_app (tenant_id varchar(20), label varchar(20)) ENGINE=InnoDB;
|
||||
CREATE TABLE aihr_knowledge_app_space (tenant_id varchar(20), label varchar(20)) ENGINE=InnoDB;
|
||||
@@ -56,4 +59,31 @@ aligned_columns="$(mysql "$DB" -N -B -e "
|
||||
")"
|
||||
test "$aligned_columns" = '38'
|
||||
|
||||
echo "PASS: AIHR release tables inherit the target database collation and the migration is idempotent"
|
||||
mysql "$DB" < "$ROOT_DIR/backend/script/sql/update/aihr_20260804_unify_all_collations_mysql8.sql"
|
||||
mysql "$DB" < "$ROOT_DIR/backend/script/sql/update/aihr_20260804_unify_all_collations_mysql8.sql"
|
||||
|
||||
noncanonical_columns="$(mysql "$DB" -N -B -e "
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema='$DB'
|
||||
AND table_name LIKE 'aihr\\_%' ESCAPE '\\\\'
|
||||
AND character_set_name IS NOT NULL
|
||||
AND (character_set_name <> 'utf8mb4' OR collation_name <> 'utf8mb4_0900_ai_ci');
|
||||
")"
|
||||
test "$noncanonical_columns" = '0'
|
||||
|
||||
mysql "$DB" <<'SQL'
|
||||
INSERT INTO aihr_knowledge_info VALUES ('000000');
|
||||
INSERT INTO aihr_knowledge_fragment VALUES ('000000', '片段');
|
||||
INSERT INTO aihr_data_asset VALUES ('000000', '制度');
|
||||
INSERT INTO aihr_chunk_revision VALUES ('000000', '片段');
|
||||
SQL
|
||||
|
||||
join_count="$(mysql "$DB" -N -B -e "
|
||||
SELECT COUNT(*) FROM aihr_data_asset a
|
||||
JOIN aihr_chunk_revision c ON c.tenant_id = a.tenant_id
|
||||
JOIN aihr_knowledge_fragment f ON f.tenant_id = c.tenant_id;
|
||||
" "$DB")"
|
||||
test "$join_count" = '1'
|
||||
|
||||
echo "PASS: AIHR release tables inherit the target database collation and all-AIHR normalization is idempotent"
|
||||
|
||||
Reference in New Issue
Block a user