feat(knowledge): add multi-space platform schema

This commit is contained in:
2026-07-16 10:21:35 +08:00
parent 5a131b57ef
commit 735e9a78c1
3 changed files with 281 additions and 6 deletions
@@ -0,0 +1,44 @@
package org.dromara.aihr.service;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("dev")
class AihrKnowledgePlatformSchemaTest {
@Test
void schemaDefinesSpacesAppsGrantsAndAuditWithoutPlainTokens() throws Exception {
String sql = Files.readString(repoRoot().resolve("backend/script/sql/aihr_knowledge_mysql8.sql"));
String migration = Files.readString(repoRoot().resolve(
"backend/script/sql/update/aihr_20260716_knowledge_space_platform_mysql8.sql"));
String schema = sql + migration;
assertTrue(schema.contains("`code` varchar(100)"));
assertTrue(schema.contains("uk_aihr_knowledge_info_code"));
assertTrue(schema.contains("aihr_knowledge_space_grant"));
assertTrue(schema.contains("aihr_knowledge_app"));
assertTrue(schema.contains("aihr_knowledge_app_space"));
assertTrue(schema.contains("aihr_knowledge_query_log"));
assertTrue(schema.contains("space_codes_json"));
assertTrue(schema.contains("token_hash"));
assertFalse(schema.contains("token_plain"));
assertFalse(schema.contains("aihr_personal_"));
}
private static Path repoRoot() {
Path current = Path.of("").toAbsolutePath();
while (current != null && !Files.exists(current.resolve("backend/script/sql"))) {
current = current.getParent();
}
if (current == null) {
throw new IllegalStateException("repository root not found");
}
return current;
}
}