feat(M02-C): 建立RBAC与门店数据范围

This commit is contained in:
Codex
2026-06-18 10:50:43 +08:00
parent a8c2a3b3e1
commit caacc78545
16 changed files with 334 additions and 16 deletions
+14 -1
View File
@@ -21,6 +21,9 @@ const tenantAppsVerifySql = read('database/migrations/2026061803_m02a_tenant_app
const authUpSql = read('database/migrations/2026061804_m02b_wechat_auth.up.sql');
const authDownSql = read('database/migrations/2026061804_m02b_wechat_auth.down.sql');
const authVerifySql = read('database/migrations/2026061804_m02b_wechat_auth.verify.sql');
const rbacUpSql = read('database/migrations/2026061805_m02c_rbac.up.sql');
const rbacDownSql = read('database/migrations/2026061805_m02c_rbac.down.sql');
const rbacVerifySql = read('database/migrations/2026061805_m02c_rbac.verify.sql');
const coreTables = [
'qipai_schema_migrations',
@@ -112,4 +115,14 @@ assert.match(authUpSql, /UNIQUE KEY uq_qipai_user_identities_tenant_app_openid/)
assert.match(authUpSql, /revoked_at DATETIME\(3\)/);
assert.match(authUpSql, /expires_at DATETIME\(3\)/);
console.log('PASS: M01-B through M02-B migration contracts are present.');
for (const table of [
'qipai_permissions', 'qipai_roles', 'qipai_role_permissions',
'qipai_user_roles', 'qipai_user_store_scopes'
]) {
assert.match(rbacUpSql, new RegExp(`CREATE TABLE IF NOT EXISTS ${table}\\b`));
assert.match(rbacDownSql, new RegExp(`DROP TABLE IF EXISTS ${table}\\b`));
assert.match(rbacVerifySql, new RegExp(`'${table}'`));
}
assert.match(rbacUpSql, /PRIMARY KEY \(tenant_id, user_id, store_id, scope_type\)/);
console.log('PASS: M01-B through M02-C migration contracts are present.');