From 72caefaaf2dedaebb7abfb63cedbf12116699530 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Tue, 31 Jan 2023 11:50:41 +0800 Subject: [PATCH] refactor: update per review --- .changeset-staged/three-ducks-yell.md | 2 +- packages/cli/src/queries/system.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.changeset-staged/three-ducks-yell.md b/.changeset-staged/three-ducks-yell.md index b89219e9b..8833cd095 100644 --- a/.changeset-staged/three-ducks-yell.md +++ b/.changeset-staged/three-ducks-yell.md @@ -12,6 +12,6 @@ drop settings table and add systems table - core: removed `GET /settings` and `PATCH /settings` API - core: added `GET /configs/admin-console` and `PATCH /configs/admin-console` API - `/configs/*` APIs are config/key-specific now. they may have different logic per key -- cli: removed `alterationState` and added `adminConsole` in valid `logto db config` keys, since: +- cli: change valid `logto db config` keys by removing `alterationState` and adding `adminConsole` since: - OIDC configs and admin console configs are tenant-level configs (the concept of "tenant" can be ignored until we officially announce it) - alteration state is still a system-wide config diff --git a/packages/cli/src/queries/system.ts b/packages/cli/src/queries/system.ts index 546050bb9..f5ccd18f8 100644 --- a/packages/cli/src/queries/system.ts +++ b/packages/cli/src/queries/system.ts @@ -19,10 +19,12 @@ const doesTableExist = async (pool: CommonQueryMethods, table: string) => { export const doesSystemsTableExist = async (pool: CommonQueryMethods) => doesTableExist(pool, Systems.table); +const legacyLogtoConfigsTable = '_logto_configs'; + const getAlterationStateTable = async (pool: CommonQueryMethods) => (await doesSystemsTableExist(pool)) ? sql.identifier([Systems.table]) - : sql.identifier(['_logto_configs']); // Fall back to the old config table + : sql.identifier([legacyLogtoConfigsTable]); // Fall back to the old config table export const getCurrentDatabaseAlterationTimestamp = async (pool: CommonQueryMethods) => { const table = await getAlterationStateTable(pool);