mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schemas): add alteration for default ac role scope (#2957)
This commit is contained in:
parent
ace9a01327
commit
e2857d554f
1 changed files with 29 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
import { sql } from 'slonik';
|
||||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
const managementResourceScopeId = 'management-api-scope';
|
||||
const adminConsoleAdminRoleId = 'ac-admin-id';
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
const relation = await pool.maybeOne(sql`
|
||||
select * from roles_scopes
|
||||
where scope_id = ${managementResourceScopeId}
|
||||
and role_id = ${adminConsoleAdminRoleId}
|
||||
`);
|
||||
|
||||
if (!relation) {
|
||||
await pool.query(sql`
|
||||
insert into roles_scopes
|
||||
(role_id, scope_id)
|
||||
values (${adminConsoleAdminRoleId}, ${managementResourceScopeId})
|
||||
`);
|
||||
}
|
||||
},
|
||||
down: async () => {
|
||||
// This is a hotfix for seed, down script is not needed
|
||||
},
|
||||
};
|
||||
|
||||
export default alteration;
|
Loading…
Reference in a new issue