Skip to content

Commit

Permalink
Fix running postgrator 0
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Nov 30, 2021
1 parent 8bdbc83 commit 978d350
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/postgrator-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ const getDefaults = (loadPath) => {
};

const getPostgratorOptions = (options) => ({
...(options.to ? { to: getMigrateToNumber(options.to) } : {}),
...(options.driver ? { driver: options.driver } : {}),
...(options.database ? { database: options.database } : {}),
...(options['migration-pattern'] ? { migrationPattern: getAbsolutePath(options['migration-pattern']) } : {}),
...(options['schema-table'] ? { schemaTable: options['schema-table'] } : {}),
...(options['validate-checksum'] ? { validateChecksum: options['validate-checksum'] } : {}),
...('to' in options ? { to: getMigrateToNumber(options.to) } : {}),
...('driver' in options ? { driver: options.driver } : {}),
...('database' in options ? { database: options.database } : {}),
...('migration-pattern' in options ? { migrationPattern: getAbsolutePath(options['migration-pattern']) } : {}),
...('schema-table' in options ? { schemaTable: options['schema-table'] } : {}),
...('validate-checksum' in options ? { validateChecksum: options['validate-checksum'] } : {}),
});

const getClientOptions = async (options) => ({
...(options.host ? { host: options.host } : {}),
...(options.port ? { port: options.port } : {}),
...(options.database ? { database: options.database } : {}),
...(options.username ? { username: options.username } : {}),
...(options.ssl ? { ssl: options.ssl } : {}),
...('host' in options ? { host: options.host } : {}),
...('port' in options ? { port: options.port } : {}),
...('database' in options ? { database: options.database } : {}),
...('username' in options ? { username: options.username } : {}),
...('ssl' in options ? { ssl: options.ssl } : {}),
...(
options.password // eslint-disable-line no-nested-ternary
? { password: options.password }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"postgrator": "./index.js"
},
"engines": {
"node": ">=12.2.0"
"node": ">=12.22.0"
},
"scripts": {
"lint": "eslint --cache .",
Expand Down
9 changes: 9 additions & 0 deletions test/postgrator-cli-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ function buildTestsForOptions(options) {
.to.become(undefined);
});

tests.push(async () => {
console.log('\n----- testing dropping schema table with default configuration file -----');

return mockCwd(path.join(__dirname, 'sample-config'), async () => {
await expect(run(['0'])).to.eventually.have.lengthOf(0);
await expect(run(['drop-schema'])).to.become(undefined);
});
});

tests.push(async () => {
console.log('\n----- testing dropping schema when the table name is specified explicitly -----');
const args = getArgList({
Expand Down

0 comments on commit 978d350

Please sign in to comment.