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 3.15.0 to 3.16.0

6

CHANGELOG.md
# Change Log
## [3.16.0](2019-02-08)
### Added
- Adding LIKE options when creating table [#394](https://github.com/salsita/node-pg-migrate/pull/394)
## [3.15.0](2019-01-28)

@@ -4,0 +10,0 @@

10

dist/operations/tables.js

@@ -172,2 +172,10 @@ "use strict";

return deferrable ? constraints.map(constraint => `${constraint} ${parseDeferrable(options)}`) : constraints;
};
const parseLike = like => {
const formatOptions = (name, options) => (_.isArray(options) ? options : [options]).map(option => ` ${name} ${option}`).join("");
const table = typeof like === "string" || !like.table ? like : like.table;
const options = like.options ? [formatOptions("INCLUDING", like.options.including), formatOptions("EXCLUDING", like.options.excluding)].join("") : "";
return template`LIKE "${table}"${options}`;
}; // TABLE

@@ -211,3 +219,3 @@

const constraintLines = parseConstraints(tableName, constraints, true);
const tableDefinition = [...columnLines, ...constraintLines].concat(like ? [template`LIKE "${like}"`] : []);
const tableDefinition = [...columnLines, ...constraintLines].concat(like ? [parseLike(like)] : []);
const temporaryStr = temporary ? " TEMPORARY" : "";

@@ -214,0 +222,0 @@ const ifNotExistsStr = ifNotExists ? " IF NOT EXISTS" : "";

@@ -16,3 +16,9 @@ # Table Operations

- `constraints` _[object]_ - table constraints see [add constraint](constraints.md#pgmaddconstraint-tablename-constraint_name-expression-)
- `like` _[[Name](migrations.md#type)]_ - table(s) to inherit from
- `like` either:
- _[[Name](migrations.md#type)]_ - table(s) to inherit from
- or _[object]_
- `table` _[[Name](migrations.md#type)]_ - table(s) to inherit from
- `options` _[object]_ - like options (optional)
- `including` _[string or array of strings]_ - 'COMMENTS', 'CONSTRAINTS', 'DEFAULTS', 'IDENTITY', 'INDEXES', 'STATISTICS', 'STORAGE', 'ALL'
- `excluding` _[string or array of strings]_ - 'COMMENTS', 'CONSTRAINTS', 'DEFAULTS', 'IDENTITY', 'INDEXES', 'STATISTICS', 'STORAGE', 'ALL'
- `comment` _[string]_ - adds comment on table

@@ -19,0 +25,0 @@

@@ -53,2 +53,9 @@ // Type definitions for node-pg-migrate

export type Like = 'COMMENTS' | 'CONSTRAINTS' | 'DEFAULTS' | 'IDENTITY' | 'INDEXES' | 'STATISTICS' | 'STORAGE' | 'ALL'
export interface LikeOptions {
including?: Like | Like[]
excluding?: Like | Like[]
}
export interface TableOptions {

@@ -58,3 +65,3 @@ temporary?: boolean

inherits?: Name
like?: Name
like?: Name | { table: Name, options?: LikeOptions }
constraints?: ConstraintOptions

@@ -61,0 +68,0 @@ comment?: string | null

@@ -188,2 +188,18 @@ const _ = require("lodash");

const parseLike = like => {
const formatOptions = (name, options) =>
(_.isArray(options) ? options : [options])
.map(option => ` ${name} ${option}`)
.join("");
const table = typeof like === "string" || !like.table ? like : like.table;
const options = like.options
? [
formatOptions("INCLUDING", like.options.including),
formatOptions("EXCLUDING", like.options.excluding)
].join("")
: "";
return template`LIKE "${table}"${options}`;
};
// TABLE

@@ -225,3 +241,3 @@ function dropTable(tableName, { ifExists, cascade } = {}) {

const tableDefinition = [...columnLines, ...constraintLines].concat(
like ? [template`LIKE "${like}"`] : []
like ? [parseLike(like)] : []
);

@@ -228,0 +244,0 @@

10

package.json
{
"name": "node-pg-migrate",
"version": "3.15.0",
"version": "3.16.0",
"description": "Postgresql database migration management tool for node.js",

@@ -62,13 +62,13 @@ "author": "Theo Ephraim",

"dotenv": "6.2.0",
"eslint": "5.12.1",
"eslint": "5.13.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-config-prettier": "4.0.0",
"eslint-plugin-import": "2.15.0",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-security": "1.4.0",
"husky": "1.3.1",
"lint-staged": "8.1.0",
"lint-staged": "8.1.3",
"mocha": "5.2.0",
"pg": "7.8.0",
"prettier": "1.16.1",
"prettier": "1.16.4",
"proxyquire": "2.1.0",

@@ -75,0 +75,0 @@ "sinon": "7.2.3",

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