New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vbilopav/pgmigrations

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vbilopav/pgmigrations - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

2

package.json
{
"name": "@vbilopav/pgmigrations",
"version": "0.1.1",
"version": "0.2.0",
"description": "PostgreSQL Migration Tool for Node.js and NPM",

@@ -5,0 +5,0 @@ "author": "vb-consulting",

@@ -16,3 +16,6 @@ #!/usr/bin/env node

function buildConfig(userConfig, opt) {
var userConfigs = [defaultconfigFile];
function buildConfig(opt) {
/*
var configFile;

@@ -47,3 +50,25 @@ if (userConfig) {

}
*/
for (var i = 0; i < userConfigs.length; i++) {
var configFile = path.join(process.cwd(), userConfigs[i]);
if (fs.existsSync(configFile) && fs.lstatSync(configFile).isFile()) {
if (opt.verbose) {
console.log("Using default config file: " + configFile);
}
var config = require(configFile);
for (var key in config) {
if (mainConfig[key] === undefined) {
error("Unknown config key: " + key +". Please provide a valid config key.");
return;
}
mainConfig[key] = config[key];
}
} else if (userConfigs[i] !== defaultconfigFile) {
warning("Config file not found: " + configFile + ". Please provide a valid config file.");
}
}
if (mainConfig.env) {

@@ -133,2 +158,3 @@ var envFile = ".env";

{key: "test", value: "Run database tests."},
{key: "config", value: "console.log the current configuration."},
], 16);

@@ -147,5 +173,6 @@

console.log('\nConfig file:');
console.log('\nConfigurations files:');
sections([
{key: '--config=[file]', value: 'Set the custom config file instead of the default config file (db.js). This switch applies to all commands.'}
{key: '', value: './db.js from the current dir is the default configuration file. It will be ignored if not found.'},
{key: '--config=[file]', value: 'Set the custom config file or multiple files (multiple --config switches). Config files are merged in the order they are provided.'}
], 16);

@@ -165,3 +192,2 @@

let dump = false;
let userConfig;

@@ -188,3 +214,3 @@ for (let i = 0; i < options.length; i++) {

}
userConfig = parts[1];
userConfigs.push(parts[1]);
} else {

@@ -203,3 +229,3 @@ error("Unknown option: " + opt + ". Please provide a valid option");

const opt = {list, dry, dump, full, verbose};
const config = buildConfig(userConfig, opt);
const config = buildConfig(opt);
opt.verbose = opt.verbose || config.verbose;

@@ -211,3 +237,2 @@ migrate(cmd, opt, config);

let command;
let userConfig;
let additionalArgs = [];

@@ -227,3 +252,3 @@

}
userConfig = parts[1];
userConfigs.push(parts[1]);
} else {

@@ -248,3 +273,3 @@ additionalArgs.push(opt);

const opt = {verbose};
const config = buildConfig(userConfig, opt);
const config = buildConfig(opt);
opt.verbose = opt.verbose || config.verbose;

@@ -255,3 +280,2 @@ commandRunner(command, opt, additionalArgs, config);

let userConfig;
let additionalArgs = [];

@@ -271,3 +295,3 @@

}
userConfig = parts[1];
userConfigs.push(parts[1]);
} else {

@@ -283,3 +307,3 @@ additionalArgs.push(opt);

const opt = {verbose};
const config = buildConfig(userConfig, opt);
const config = buildConfig(opt);
opt.verbose = opt.verbose || config.verbose;

@@ -290,3 +314,2 @@ schema(opt, additionalArgs, config);

let userConfig;
let additionalArgs = [];

@@ -306,3 +329,3 @@

}
userConfig = parts[1];
userConfigs.push(parts[1]);
} else {

@@ -318,3 +341,3 @@ additionalArgs.push(opt);

const opt = {verbose};
const config = buildConfig(userConfig, opt);
const config = buildConfig(opt);
opt.verbose = opt.verbose || config.verbose;

@@ -326,3 +349,2 @@ psql(opt, additionalArgs, config);

let list = false;
let userConfig;

@@ -343,3 +365,3 @@ for (let i = 0; i < options.length; i++) {

}
userConfig = parts[1];
userConfigs.push(parts[1]);
} else {

@@ -353,6 +375,31 @@ error("Unknown option: " + opt + ". Please provide a valid option");

const opt = {list, verbose};
const config = buildConfig(userConfig, opt);
const config = buildConfig(opt);
opt.verbose = opt.verbose || config.verbose;
tests(opt, config);
} else if (cmd == "config") {
for (let i = 0; i < options.length; i++) {
let opt = options[i];
if (opt.startsWith("-")) {
if (opt == "--verbose") {
verbose = true;
} else if (opt.startsWith("--config")) {
let parts = opt.split("=");
if (parts.length <= 1) {
error("Config file is required. Please provide a valid config file.");
return;
}
userConfigs.push(parts[1]);
} else {
error("Unknown option: " + opt + ". Please provide a valid option");
return;
}
}
}
const config = buildConfig({verbose});
console.log(config);
} else {

@@ -359,0 +406,0 @@

@@ -23,13 +23,14 @@ # PgMigrations

Commands:
up Run migrations migrations in order: before, before repeatable, up, repeatable, after. Optional switches: --list, --dry, --full, --dump.
down Run only down migrations. Optional switches: --list, --dry, --full, --dump.
run | exec Run a command or a script file with psql. Command text or a script file is required as the second argument. Any additional arguments will be passed to a psql command.
dump | schema Run pg_dump command with --schema-only --encoding=UTF8 swtiches on (plus schemaDumpAdditionalArgs from the config). Any additional arguments will be passed to pg_dump command.
psql Run arbitrary psql command or open psql shell. Any additional arguments will be passed to a psql.
test Run database tests.
up Run migrations migrations in order: before, before repeatable, up, repeatable, after. Optional switches: --list, --dry, --full, --dump.
down Run only down migrations. Optional switches: --list, --dry, --full, --dump.
run | exec Run a command or a script file with psql. Command text or a script file is required as the second argument. Any additional arguments will be passed to a psql command.
dump | schema Run pg_dump command with --schema-only --encoding=UTF8 swtiches on (plus schemaDumpAdditionalArgs from the config). Any additional arguments will be passed to pg_dump command.
psql Run arbitrary psql command or open psql shell. Any additional arguments will be passed to a psql.
test Run database tests.
config console.log the current configuration.
Switches:
-h, --help Show help
--list List available migrations in this direction (up or down) or list available database tests.
--dry Run in the migrations dry run mode on database in this direction (up or down). No changes will be made to the database (rollbacks changes).
-h, --help Show help
--list List available migrations in this direction (up or down) or list available database tests.
--dry Run in the migrations dry run mode on database in this direction (up or down). No changes will be made to the database (rollbacks changes).
--full Executes all migrations in this direction (up or down). Schema history will be ignored.

@@ -39,4 +40,5 @@ --dump Dump the SQL for the migration to the console instead of executing it.

Config file:
--config=[file] Set the custom config file instead of the default config file (db.js). This switch applies to all commands.
Configurations files:
./db.js from the current dir is the default configuration file. It will be ignored if not found.
--config=[file] Set the custom config file or multiple files (multiple --config switches). Config files are merged in the order they are provided.
```

@@ -181,6 +183,8 @@

The tool will try to read the default configuration file from the running location. The default configuration file is `db.js` or it can be set with a command line switch `--config=[file]`.
The tool will try to read the default configuration file from the running location: `db.js`.
Example:
Additional configuration files can be loaded with a command line switch `--config=[file]`. They will be loaded and merged in the order they appear, while the default configuration `db.js` is always first (if it exists).
Example of the configuration file:
```js

@@ -187,0 +191,0 @@ module.exports = {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc