mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
fix(schemas): add alteration for default ac scope (#2953)
This commit is contained in:
parent
9bcb11a2d8
commit
d559937e8b
1 changed files with 33 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
import { sql } from 'slonik';
|
||||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
const managementResourceScopeId = 'management-api-scope';
|
||||
const managementResourceId = 'management-api';
|
||||
const managementResourceScope = Object.freeze({
|
||||
id: managementResourceScopeId,
|
||||
name: 'management-api:default',
|
||||
description: 'Default scope for management API',
|
||||
resourceId: managementResourceId,
|
||||
});
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
const scope = await pool.maybeOne(sql`
|
||||
select * from scopes where id =${managementResourceScopeId}
|
||||
`);
|
||||
|
||||
if (!scope) {
|
||||
await pool.query(sql`
|
||||
insert into scopes
|
||||
(id, name, description, resource_id)
|
||||
values (${managementResourceScope.id}, ${managementResourceScope.name}, ${managementResourceScope.description}, ${managementResourceScope.resourceId})
|
||||
`);
|
||||
}
|
||||
},
|
||||
down: async () => {
|
||||
// This is a hotfix for seed, down script is not needed
|
||||
},
|
||||
};
|
||||
|
||||
export default alteration;
|
Loading…
Add table
Reference in a new issue