From 9ec3a8fcb7498a320feff10d2c31e96778b59e47 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Thu, 12 Jan 2023 16:33:14 +0800 Subject: [PATCH] fix(schemas): modify management api default scope name (#2920) --- .../next-1673465463-ac-scope-name.ts | 22 +++++++++++++++++++ packages/schemas/src/seeds/scope.ts | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/schemas/alterations/next-1673465463-ac-scope-name.ts diff --git a/packages/schemas/alterations/next-1673465463-ac-scope-name.ts b/packages/schemas/alterations/next-1673465463-ac-scope-name.ts new file mode 100644 index 000000000..49cbef454 --- /dev/null +++ b/packages/schemas/alterations/next-1673465463-ac-scope-name.ts @@ -0,0 +1,22 @@ +import { sql } from 'slonik'; + +import type { AlterationScript } from '../lib/types/alteration.js'; + +const newScopeName = 'management-api:default'; +const oldScopeName = 'default'; +const recordId = 'management-api-scope'; + +const alteration: AlterationScript = { + up: async (pool) => { + await pool.query(sql` + update scopes set name = ${newScopeName} where id = ${recordId} + `); + }, + down: async (pool) => { + await pool.query(sql` + update scopes set name = ${oldScopeName} where id = ${recordId} + `); + }, +}; + +export default alteration; diff --git a/packages/schemas/src/seeds/scope.ts b/packages/schemas/src/seeds/scope.ts index 8ae8be430..7eb942d37 100644 --- a/packages/schemas/src/seeds/scope.ts +++ b/packages/schemas/src/seeds/scope.ts @@ -5,7 +5,7 @@ export const managementResourceScopeId = 'management-api-scope'; export const managementResourceScope: Readonly = Object.freeze({ id: managementResourceScopeId, - name: 'default', + name: 'management-api:default', description: 'Default scope for management API', resourceId: managementResourceId, });