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 5.6.0 to 5.7.0

10

CHANGELOG.md
# Change Log
## [5.7.0](2020-09-21)
### Added
- `pgm.sql` can also accept `PgLiteral`, `number`, `boolean`, `null`, `array` [#695](https://github.com/salsita/node-pg-migrate/pull/695)
## [5.6.0](2020-08-19)
### PgLiteral can be serialized
### Added
- Do not try to unlock DB if connection failed [#678](https://github.com/salsita/node-pg-migrate/pull/678)
- PgLiteral can be serialized [#678](https://github.com/salsita/node-pg-migrate/pull/678)

@@ -9,0 +15,0 @@ ## [5.5.1](2020-08-18)

4

dist/migration.d.ts

@@ -5,4 +5,2 @@ import { DBConnection } from './db';

import { ColumnDefinitions } from './operations/tablesTypes';
export declare const loadMigrationFiles: (dir: string, ignorePattern?: string | undefined) => Promise<string[]>;
export declare const getTimestamp: (logger: Logger, filename: string) => number;
export interface RunMigration {

@@ -27,2 +25,4 @@ readonly path: string;

} & (CreateOptionsTemplate | CreateOptionsDefault);
export declare const loadMigrationFiles: (dir: string, ignorePattern?: string | undefined) => Promise<string[]>;
export declare const getTimestamp: (logger: Logger, filename: string) => number;
export declare class Migration implements RunMigration {

@@ -29,0 +29,0 @@ static create(name: string, directory: string, _language?: 'js' | 'ts' | 'sql' | CreateOptions, _ignorePattern?: string, _filenameFormat?: FilenameFormat): Promise<string>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Migration = exports.FilenameFormat = exports.getTimestamp = exports.loadMigrationFiles = void 0;
exports.Migration = exports.getTimestamp = exports.loadMigrationFiles = exports.FilenameFormat = void 0;
const fs_1 = __importDefault(require("fs"));

@@ -14,2 +14,7 @@ const mkdirp_1 = __importDefault(require("mkdirp"));

const { readdir } = fs_1.default.promises;
var FilenameFormat;
(function (FilenameFormat) {
FilenameFormat["timestamp"] = "timestamp";
FilenameFormat["utc"] = "utc";
})(FilenameFormat = exports.FilenameFormat || (exports.FilenameFormat = {}));
const SEPARATOR = '_';

@@ -56,7 +61,2 @@ exports.loadMigrationFiles = async (dir, ignorePattern) => {

const resolveSuffix = async (directory, { language, ignorePattern }) => language || (await getLastSuffix(directory, ignorePattern)) || 'js';
var FilenameFormat;
(function (FilenameFormat) {
FilenameFormat["timestamp"] = "timestamp";
FilenameFormat["utc"] = "utc";
})(FilenameFormat = exports.FilenameFormat || (exports.FilenameFormat = {}));
class Migration {

@@ -63,0 +63,0 @@ constructor(db, migrationPath, { up, down }, options, typeShorthands, logger = console) {

@@ -9,6 +9,5 @@ "use strict";

function dropExtension(mOptions) {
const _drop = (extensions, options = {}) => {
const _drop = (_extensions, options = {}) => {
const { ifExists, cascade } = options;
if (!lodash_1.default.isArray(extensions))
extensions = [extensions];
const extensions = lodash_1.default.isArray(_extensions) ? _extensions : [_extensions];
const ifExistsStr = ifExists ? ' IF EXISTS' : '';

@@ -25,6 +24,5 @@ const cascadeStr = cascade ? ' CASCADE' : '';

function createExtension(mOptions) {
const _create = (extensions, options = {}) => {
const _create = (_extensions, options = {}) => {
const { ifNotExists, schema } = options;
if (!lodash_1.default.isArray(extensions))
extensions = [extensions];
const extensions = lodash_1.default.isArray(_extensions) ? _extensions : [_extensions];
const ifNotExistsStr = ifNotExists ? ' IF NOT EXISTS' : '';

@@ -31,0 +29,0 @@ const schemaStr = schema ? ` SCHEMA ${mOptions.literal(schema)}` : '';

@@ -0,4 +1,5 @@

import { Value } from '..';
import { Name } from './generalTypes';
export declare type Sql = (sqlStr: string, args?: {
[key: string]: Name;
[key: string]: Name | Value;
}) => string | string[];

@@ -113,2 +113,9 @@ /// <reference types="node" />

export declare type Literal = (v: Name) => string;
export declare type LogFn = (msg: string) => void;
export declare type Logger = {
debug?: LogFn;
info: LogFn;
warn: LogFn;
error: LogFn;
};
export interface MigrationBuilderActions {

@@ -185,9 +192,2 @@ up?: MigrationAction | false;

export declare type MigrationDirection = 'up' | 'down';
export declare type LogFn = (msg: string) => void;
export declare type Logger = {
debug?: LogFn;
info: LogFn;
warn: LogFn;
error: LogFn;
};
export interface RunnerOptionConfig {

@@ -194,0 +194,0 @@ migrationsTable: string;

@@ -5,7 +5,11 @@ import { ColumnDefinitions, ColumnDefinition } from './operations/tablesTypes';

import { FunctionParam, FunctionParamType } from './operations/functionsTypes';
import { PgLiteral } from '.';
export declare const createSchemalize: (shouldDecamelize: boolean, shouldQuote: boolean) => (v: Name) => string;
export declare const escapeValue: (val: Value) => string | number;
export declare const createTransformer: (literal: Literal) => (s: string, d?: {
[key: string]: Name;
[key: string]: string | number | boolean | PgLiteral | import("./operations/generalTypes").PublicPart<PgLiteral> | Value[] | {
schema?: string | undefined;
name: string;
} | null;
} | undefined) => string;
export declare const escapeValue: (val: Value) => string | number;
export declare const getSchemas: (schema?: string | string[] | undefined) => string[];

@@ -12,0 +16,0 @@ export declare const getMigrationTableSchema: (options: RunnerOption) => string;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,3 +17,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.formatLines = exports.makeComment = exports.formatParams = exports.applyType = exports.applyTypeAdapters = exports.getMigrationTableSchema = exports.getSchemas = exports.escapeValue = exports.createTransformer = exports.createSchemalize = void 0;
exports.formatLines = exports.makeComment = exports.formatParams = exports.applyType = exports.applyTypeAdapters = exports.getMigrationTableSchema = exports.getSchemas = exports.createTransformer = exports.escapeValue = exports.createSchemalize = void 0;
const decamelize_1 = __importDefault(require("decamelize"));

@@ -21,3 +32,3 @@ const identity = (v) => v;

};
exports.createTransformer = (literal) => (s, d) => Object.keys(d || {}).reduce((str, p) => str.replace(new RegExp(`{${p}}`, 'g'), d === undefined || d[p] === undefined ? '' : literal(d[p])), s);
const isPgLiteral = (val) => typeof val === 'object' && val !== null && 'literal' in val && val.literal === true;
exports.escapeValue = (val) => {

@@ -46,3 +57,3 @@ if (val === null) {

}
if (typeof val === 'object' && val.literal) {
if (isPgLiteral(val)) {
return val.value;

@@ -52,2 +63,6 @@ }

};
exports.createTransformer = (literal) => (s, d) => Object.keys(d || {}).reduce((str, p) => {
const v = d === null || d === void 0 ? void 0 : d[p];
return str.replace(new RegExp(`{${p}}`, 'g'), v === undefined ? '' : typeof v === 'object' && v !== null && 'name' in v ? literal(v) : String(exports.escapeValue(v)));
}, s);
exports.getSchemas = (schema) => {

@@ -70,13 +85,15 @@ const schemas = (Array.isArray(schema) ? schema : [schema]).filter((s) => typeof s === 'string' && s.length > 0);

exports.applyTypeAdapters = (type) => type in typeAdapters ? typeAdapters[type] : type;
const toType = (type) => (typeof type === 'string' ? { type } : type);
const removeType = (_a) => {
var { type } = _a, rest = __rest(_a, ["type"]);
return rest;
};
exports.applyType = (type, extendingTypeShorthands = {}) => {
var _a;
const typeShorthands = Object.assign(Object.assign({}, defaultTypeShorthands), extendingTypeShorthands);
const options = typeof type === 'string' ? { type } : type;
const options = toType(type);
let ext = null;
const types = [options.type];
while (typeShorthands[types[types.length - 1]]) {
if (ext) {
delete ext.type;
}
const t = typeShorthands[types[types.length - 1]];
ext = Object.assign(Object.assign({}, (typeof t === 'string' ? { type: t } : t)), (ext === null ? {} : ext));
ext = Object.assign(Object.assign({}, toType(typeShorthands[types[types.length - 1]])), (ext === null ? {} : removeType(ext)));
if (types.includes(ext.type)) {

@@ -89,6 +106,3 @@ throw new Error(`Shorthands contain cyclic dependency: ${types.join(', ')}, ${ext.type}`);

}
if (!ext) {
ext = { type: options.type };
}
return Object.assign(Object.assign(Object.assign({}, ext), options), { type: exports.applyTypeAdapters(ext.type) });
return Object.assign(Object.assign(Object.assign({}, ext), options), { type: exports.applyTypeAdapters((_a = ext === null || ext === void 0 ? void 0 : ext.type) !== null && _a !== void 0 ? _a : options.type) });
};

@@ -95,0 +109,0 @@ const formatParam = (mOptions) => (param) => {

{
"name": "node-pg-migrate",
"version": "5.6.0",
"version": "5.7.0",
"description": "Postgresql database migration management tool for node.js",
"author": "Theo Ephraim",
"contributors": ["Salsita Software <jando@salsitasoft.com>", "Christopher Quadflieg <chrissi92@hotmail.de>"],
"contributors": [
"Salsita Software <jando@salsitasoft.com>",
"Christopher Quadflieg <chrissi92@hotmail.de>"
],
"bin": {

@@ -49,3 +52,3 @@ "node-pg-migrate": "bin/node-pg-migrate"

"mkdirp": "~1.0.0",
"yargs": "~15.4.0"
"yargs": "~16.0.0"
},

@@ -55,10 +58,10 @@ "devDependencies": {

"@types/chai-as-promised": "7.1.3",
"@types/lodash": "4.14.159",
"@types/lodash": "4.14.161",
"@types/mkdirp": "1.0.1",
"@types/mocha": "8.0.2",
"@types/mocha": "8.0.3",
"@types/proxyquire": "1.3.28",
"@types/sinon": "9.0.4",
"@types/sinon": "9.0.5",
"@types/sinon-chai": "3.2.4",
"@typescript-eslint/eslint-plugin": "3.9.0",
"@typescript-eslint/parser": "3.9.0",
"@typescript-eslint/eslint-plugin": "3.10.1",
"@typescript-eslint/parser": "3.10.1",
"chai": "4.2.0",

@@ -70,15 +73,15 @@ "chai-as-promised": "7.1.1",

"dotenv": "8.2.0",
"eslint": "7.7.0",
"eslint": "7.9.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-import-resolver-typescript": "2.2.1",
"eslint-import-resolver-typescript": "2.3.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-security": "1.4.0",
"husky": "4.2.5",
"husky": "4.3.0",
"json5": "2.1.3",
"lint-staged": "10.2.11",
"mocha": "8.1.1",
"pg": "8.3.0",
"prettier": "2.0.5",
"lint-staged": "10.4.0",
"mocha": "8.1.3",
"pg": "8.3.3",
"prettier": "2.1.2",
"proxyquire": "2.1.3",

@@ -88,4 +91,4 @@ "rimraf": "3.0.2",

"sinon-chai": "3.5.0",
"ts-node": "8.10.2",
"typescript": "3.9.7"
"ts-node": "9.0.0",
"typescript": "4.0.3"
},

@@ -111,5 +114,9 @@ "peerDependencies": {

"lint-staged": {
"*.js": ["npm run lintfix"],
"*.{json,md}": ["prettier --write"]
"*.js": [
"npm run lintfix"
],
"*.{json,md}": [
"prettier --write"
]
}
}
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