Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-pg-migrate

Package Overview
Dependencies
Maintainers
3
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-pg-migrate - npm Package Compare versions

Comparing version 7.4.0 to 7.5.0-experimental-1187-0

43

bin/node-pg-migrate.js

@@ -27,2 +27,3 @@ #!/usr/bin/env node

var import_node_fs = require("node:fs");
var import_node_module = require("node:module");
var import_node_path = require("node:path");

@@ -32,2 +33,3 @@ var import_node_util = require("node:util");

var import_yargs = __toESM(require("yargs/yargs"));
const import_meta = {};
process.on("uncaughtException", (err) => {

@@ -37,9 +39,20 @@ console.error(err);

});
let xRequire;
try {
xRequire = require;
} catch (error) {
if (error instanceof ReferenceError && error.message === "require is not defined") {
xRequire = (0, import_node_module.createRequire)(
// @ts-expect-error: ignore until esm only
import_meta.url
);
}
}
function tryRequire(moduleName) {
try {
return require(moduleName);
return xRequire(moduleName);
} catch (error) {
if (
// @ts-expect-error: TS doesn't know about code property
(error == null ? void 0 : error.code) !== "MODULE_NOT_FOUND"
error?.code !== "MODULE_NOT_FOUND"
) {

@@ -354,5 +367,5 @@ throw error;

if ("url" in json && json.url) {
DB_CONNECTION ?? (DB_CONNECTION = json.url);
DB_CONNECTION ??= json.url;
} else if (isClientConfig(json)) {
DB_CONNECTION ?? (DB_CONNECTION = {
DB_CONNECTION ??= {
user: json.user,

@@ -364,6 +377,6 @@ host: json.host || "localhost",

ssl: json.ssl
});
};
}
} else {
DB_CONNECTION ?? (DB_CONNECTION = json);
DB_CONNECTION ??= json;
}

@@ -381,3 +394,3 @@ }

if (configFileName) {
const jsonConfig = require((0, import_node_path.resolve)(configFileName));
const jsonConfig = xRequire((0, import_node_path.resolve)(configFileName));
readJson(jsonConfig);

@@ -387,10 +400,10 @@ }

const action = argv._.shift();
MIGRATIONS_DIR ?? (MIGRATIONS_DIR = `${process.cwd()}/migrations`);
MIGRATIONS_FILE_LANGUAGE ?? (MIGRATIONS_FILE_LANGUAGE = "js");
MIGRATIONS_FILENAME_FORMAT ?? (MIGRATIONS_FILENAME_FORMAT = "timestamp");
MIGRATIONS_TABLE ?? (MIGRATIONS_TABLE = "pgmigrations");
SCHEMA ?? (SCHEMA = ["public"]);
IGNORE_PATTERN ?? (IGNORE_PATTERN = "\\..*");
CHECK_ORDER ?? (CHECK_ORDER = true);
VERBOSE ?? (VERBOSE = true);
MIGRATIONS_DIR ??= `${process.cwd()}/migrations`;
MIGRATIONS_FILE_LANGUAGE ??= "js";
MIGRATIONS_FILENAME_FORMAT ??= "timestamp";
MIGRATIONS_TABLE ??= "pgmigrations";
SCHEMA ??= ["public"];
IGNORE_PATTERN ??= "\\..*";
CHECK_ORDER ??= true;
VERBOSE ??= true;
if (action === "create") {

@@ -397,0 +410,0 @@ let newMigrationName = argv._.length > 0 ? argv._.join("-") : "";

@@ -9,2 +9,3 @@ #!/usr/bin/env node

import { readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { resolve } from 'node:path';

@@ -24,5 +25,21 @@ import { format } from 'node:util';

let xRequire!: NodeRequire;
try {
xRequire = require;
} catch (error) {
if (
error instanceof ReferenceError &&
error.message === 'require is not defined'
) {
xRequire = createRequire(
// @ts-expect-error: ignore until esm only
import.meta.url
);
}
}
function tryRequire<TModule = unknown>(moduleName: string): TModule | null {
try {
return require(moduleName);
return xRequire(moduleName);
} catch (error) {

@@ -431,3 +448,3 @@ if (

if (configFileName) {
const jsonConfig = require(resolve(configFileName));
const jsonConfig = xRequire(resolve(configFileName));
readJson(jsonConfig);

@@ -434,0 +451,0 @@ }

@@ -8,2 +8,3 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {

@@ -30,2 +31,3 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var migration_exports = {};

@@ -94,2 +96,22 @@ __export(migration_exports, {

class Migration {
constructor(db, migrationPath, { up, down }, options, typeShorthands, logger = console) {
__publicField(this, "db");
__publicField(this, "path");
__publicField(this, "name");
__publicField(this, "timestamp");
__publicField(this, "up");
__publicField(this, "down");
__publicField(this, "options");
__publicField(this, "typeShorthands");
__publicField(this, "logger");
this.db = db;
this.path = migrationPath;
this.name = (0, import_node_path.basename)(migrationPath, (0, import_node_path.extname)(migrationPath));
this.timestamp = getTimestamp(logger, this.name);
this.up = up;
this.down = down;
this.options = options;
this.typeShorthands = typeShorthands;
this.logger = logger;
}
// class method that creates a new migration file by cloning the migration template

@@ -103,3 +125,7 @@ static async create(name, directory, options = {}) {

__dirname,
`../templates/migration-template.${await resolveSuffix(directory, options)}`
(0, import_node_path.join)(
"..",
"templates",
`migration-template.${await resolveSuffix(directory, options)}`
)
);

@@ -113,13 +139,2 @@ const suffix = getSuffixFromFileName(templateFileName);

}
constructor(db, migrationPath, { up, down }, options, typeShorthands, logger = console) {
this.db = db;
this.path = migrationPath;
this.name = (0, import_node_path.basename)(migrationPath, (0, import_node_path.extname)(migrationPath));
this.timestamp = getTimestamp(logger, this.name);
this.up = up;
this.down = down;
this.options = options;
this.typeShorthands = typeShorthands;
this.logger = logger;
}
_getMarkAsRun(action) {

@@ -126,0 +141,0 @@ const schema = (0, import_utils.getMigrationTableSchema)(this.options);

@@ -8,2 +8,3 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {

@@ -30,2 +31,3 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var migrationBuilder_exports = {};

@@ -56,2 +58,92 @@ __export(migrationBuilder_exports, {

constructor(db, typeShorthands, shouldDecamelize, logger) {
__publicField(this, "createExtension");
__publicField(this, "dropExtension");
__publicField(this, "addExtension");
__publicField(this, "createTable");
__publicField(this, "dropTable");
__publicField(this, "renameTable");
__publicField(this, "alterTable");
__publicField(this, "addColumns");
__publicField(this, "dropColumns");
__publicField(this, "renameColumn");
__publicField(this, "alterColumn");
__publicField(this, "addColumn");
__publicField(this, "dropColumn");
__publicField(this, "addConstraint");
__publicField(this, "dropConstraint");
__publicField(this, "renameConstraint");
__publicField(this, "createConstraint");
__publicField(this, "createType");
__publicField(this, "dropType");
__publicField(this, "addType");
__publicField(this, "renameType");
__publicField(this, "renameTypeAttribute");
__publicField(this, "renameTypeValue");
__publicField(this, "addTypeAttribute");
__publicField(this, "dropTypeAttribute");
__publicField(this, "setTypeAttribute");
__publicField(this, "addTypeValue");
__publicField(this, "createIndex");
__publicField(this, "dropIndex");
__publicField(this, "addIndex");
__publicField(this, "createRole");
__publicField(this, "dropRole");
__publicField(this, "alterRole");
__publicField(this, "renameRole");
__publicField(this, "createFunction");
__publicField(this, "dropFunction");
__publicField(this, "renameFunction");
__publicField(this, "createTrigger");
__publicField(this, "dropTrigger");
__publicField(this, "renameTrigger");
__publicField(this, "createSchema");
__publicField(this, "dropSchema");
__publicField(this, "renameSchema");
__publicField(this, "createDomain");
__publicField(this, "dropDomain");
__publicField(this, "alterDomain");
__publicField(this, "renameDomain");
__publicField(this, "createSequence");
__publicField(this, "dropSequence");
__publicField(this, "alterSequence");
__publicField(this, "renameSequence");
__publicField(this, "createOperator");
__publicField(this, "dropOperator");
__publicField(this, "createOperatorClass");
__publicField(this, "dropOperatorClass");
__publicField(this, "renameOperatorClass");
__publicField(this, "createOperatorFamily");
__publicField(this, "dropOperatorFamily");
__publicField(this, "renameOperatorFamily");
__publicField(this, "addToOperatorFamily");
__publicField(this, "removeFromOperatorFamily");
__publicField(this, "createPolicy");
__publicField(this, "dropPolicy");
__publicField(this, "alterPolicy");
__publicField(this, "renamePolicy");
__publicField(this, "createView");
__publicField(this, "dropView");
__publicField(this, "alterView");
__publicField(this, "alterViewColumn");
__publicField(this, "renameView");
__publicField(this, "createMaterializedView");
__publicField(this, "dropMaterializedView");
__publicField(this, "alterMaterializedView");
__publicField(this, "renameMaterializedView");
__publicField(this, "renameMaterializedViewColumn");
__publicField(this, "refreshMaterializedView");
__publicField(this, "grantRoles");
__publicField(this, "revokeRoles");
__publicField(this, "grantOnSchemas");
__publicField(this, "revokeOnSchemas");
__publicField(this, "grantOnTables");
__publicField(this, "revokeOnTables");
__publicField(this, "createCast");
__publicField(this, "dropCast");
__publicField(this, "sql");
__publicField(this, "func");
__publicField(this, "db");
__publicField(this, "_steps");
__publicField(this, "_REVERSE_MODE");
__publicField(this, "_useTransaction");
this._steps = [];

@@ -58,0 +150,0 @@ this._REVERSE_MODE = false;

@@ -6,2 +6,3 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {

@@ -20,2 +21,3 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var PgLiteral_exports = {};

@@ -38,3 +40,3 @@ __export(PgLiteral_exports, {

*/
this.literal = true;
__publicField(this, "literal", true);
}

@@ -41,0 +43,0 @@ /**

@@ -6,2 +6,3 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {

@@ -20,2 +21,3 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var StringIdGenerator_exports = {};

@@ -29,3 +31,3 @@ __export(StringIdGenerator_exports, {

this.chars = chars;
this.ids = [0];
__publicField(this, "ids", [0]);
}

@@ -32,0 +34,0 @@ next() {

{
"name": "node-pg-migrate",
"version": "7.4.0",
"version": "7.5.0-experimental-1187-0",
"description": "PostgreSQL database migration management tool for node.js",
"scripts": {
"clean": "rimraf .eslintcache dist pnpm-lock.yaml node_modules",
"build:bin": "tsup-node --config tsup-bin.config.ts",
"build:clean": "rimraf dist",
"build:code": "tsup-node",
"build:types": "tsc --project tsconfig.build.json",
"build": "run-s build:clean build:code build:types build:bin",
"format": "prettier --cache --write .",
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .",
"ts-check": "tsc",
"test": "vitest",
"test:update-snapshots": "vitest run -u",
"test:coverage": "vitest --coverage",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"premigrate": "run-s build:bin",
"migrate": "node bin/node-pg-migrate.js",
"prepublishOnly": "pnpm run clean && pnpm install && pnpm run build",
"preflight": "pnpm install && run-s format build lint test:update-snapshots ts-check"
},
"bin": {
"node-pg-migrate": "bin/node-pg-migrate.js"
"node-pg-migrate": "bin/node-pg-migrate.js",
"node-pg-migrate-cjs": "bin/node-pg-migrate.js",
"node-pg-migrate-esm": "bin/node-pg-migrate.mjs"
},

@@ -87,4 +110,4 @@ "type": "commonjs",

"@types/yargs": "17.0.32",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"@typescript-eslint/eslint-plugin": "7.12.0",
"@typescript-eslint/parser": "7.12.0",
"@vitest/coverage-v8": "1.6.0",

@@ -106,7 +129,7 @@ "@vitest/ui": "1.6.0",

"pg": "8.11.5",
"prettier": "3.2.5",
"prettier": "3.3.0",
"prettier-plugin-organize-imports": "3.2.4",
"rimraf": "5.0.7",
"ts-node": "10.9.2",
"tsup": "8.0.2",
"tsup": "8.1.0",
"typescript": "4.8.4",

@@ -125,25 +148,6 @@ "vitepress": "1.2.2",

},
"packageManager": "pnpm@9.1.4",
"engines": {
"node": ">=16.18.0"
},
"scripts": {
"clean": "rimraf .eslintcache dist pnpm-lock.yaml node_modules",
"build:bin": "tsup-node --config tsup-bin.config.ts",
"build:clean": "rimraf dist",
"build:code": "tsup-node",
"build:types": "tsc --project tsconfig.build.json",
"build": "run-s build:clean build:code build:types build:bin",
"format": "prettier --cache --write .",
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .",
"ts-check": "tsc",
"test": "vitest",
"test:update-snapshots": "vitest run -u",
"test:coverage": "vitest --coverage",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"premigrate": "run-s build:bin",
"migrate": "node bin/node-pg-migrate.js",
"preflight": "pnpm install && run-s format build lint test:update-snapshots ts-check"
"node": ">=18.19.0"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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