0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-13 21:30:30 -05:00

fix(cli): fix skip-when-exists option (#2180)

This commit is contained in:
Gao Sun 2022-10-18 13:21:59 +08:00 committed by GitHub
parent 4d873cf6a3
commit 4ce2073692
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@ import { z } from 'zod';
import { createPoolAndDatabaseIfNeeded, insertInto } from '../../../database'; import { createPoolAndDatabaseIfNeeded, insertInto } from '../../../database';
import { import {
getRowsByKeys, getRowsByKeys,
isConfigsTableExists, doesConfigsTableExist,
updateDatabaseTimestamp, updateDatabaseTimestamp,
updateValueByKey, updateValueByKey,
} from '../../../queries/logto-config'; } from '../../../queries/logto-config';
@ -146,7 +146,7 @@ const seed: CommandModule<Record<string, unknown>, { type: string; swe?: boolean
handler: async ({ type, swe }) => { handler: async ({ type, swe }) => {
const pool = await createPoolAndDatabaseIfNeeded(); const pool = await createPoolAndDatabaseIfNeeded();
if (swe && (await isConfigsTableExists(pool))) { if (swe && (await doesConfigsTableExist(pool))) {
log.info('Seeding skipped'); log.info('Seeding skipped');
await pool.end(); await pool.end();

View file

@ -13,12 +13,12 @@ import { z } from 'zod';
const { table, fields } = convertToIdentifiers(LogtoConfigs); const { table, fields } = convertToIdentifiers(LogtoConfigs);
export const isConfigsTableExists = async (pool: DatabasePool) => { export const doesConfigsTableExist = async (pool: DatabasePool) => {
const { rows } = await pool.query<Nullable<string>>( const { rows } = await pool.query<{ regclass: Nullable<string> }>(
sql`select to_regclass(${LogtoConfigs.table})` sql`select to_regclass(${LogtoConfigs.table}) as regclass`
); );
return Boolean(rows[0]); return Boolean(rows[0]?.regclass);
}; };
export const getRowsByKeys = async ( export const getRowsByKeys = async (