mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(schemas): fix ac admin id and scope (#2965)
This commit is contained in:
parent
c1749c0489
commit
aef690778d
1 changed files with 17 additions and 1 deletions
|
@ -2,11 +2,27 @@ import { sql } from 'slonik';
|
|||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
const managementResourceScopeId = 'management-api-scope';
|
||||
const adminConsoleAdminRoleId = 'ac-admin-id';
|
||||
const adminRoleName = 'admin';
|
||||
const managementResourceScopeId = 'management-api-scope';
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
// Fix role id
|
||||
const newRole = await pool.maybeOne(sql`
|
||||
select * from roles
|
||||
where id = ${adminConsoleAdminRoleId}
|
||||
`);
|
||||
|
||||
if (!newRole) {
|
||||
await pool.query(sql`
|
||||
update roles
|
||||
set id = ${adminConsoleAdminRoleId}
|
||||
where name = ${adminRoleName}
|
||||
`);
|
||||
}
|
||||
|
||||
// Fix scope role
|
||||
const relation = await pool.maybeOne(sql`
|
||||
select * from roles_scopes
|
||||
where scope_id = ${managementResourceScopeId}
|
||||
|
|
Loading…
Reference in a new issue