Skip to content

Commit

Permalink
fix(cli): correctly validate schema (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Jun 27, 2024
1 parent 88955a5 commit 8e05e78
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bin/node-pg-migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ let MIGRATIONS_DIR = argv[migrationsDirArg];
let DB_CONNECTION: string | ConnectionParameters | ClientConfig | undefined =
process.env[argv[databaseUrlVarArg]];
let IGNORE_PATTERN = argv[ignorePatternArg];
let SCHEMA = argv[schemaArg];
let SCHEMA: string | string[] | undefined = argv[schemaArg];
let CREATE_SCHEMA = argv[createSchemaArg];
let MIGRATIONS_SCHEMA = argv[migrationsSchemaArg];
let CREATE_MIGRATIONS_SCHEMA = argv[createMigrationsSchemaArg];
Expand Down Expand Up @@ -343,8 +343,12 @@ function isClientConfig(val: unknown): val is ClientConfig & { name?: string } {

function readJson(json: unknown): void {
if (typeof json === 'object' && json !== null) {
SCHEMA = applyIf(SCHEMA, schemaArg, json, (val): val is string[] =>
Array.isArray(val)
SCHEMA = applyIf(
SCHEMA,
schemaArg,
json,
(val): val is string | string[] =>
Array.isArray(val) || (isString(val) && val.length > 0)
);
CREATE_SCHEMA = applyIf(CREATE_SCHEMA, createSchemaArg, json, isBoolean);
MIGRATIONS_DIR = applyIf(MIGRATIONS_DIR, migrationsDirArg, json, isString);
Expand Down

0 comments on commit 8e05e78

Please sign in to comment.