node-pg-migrate
Advanced tools
Comparing version 2.7.1 to 2.8.0
# Change Log | ||
## [2.8.0] (2017-09-04) | ||
### Added | ||
- Trigger operations [#104](https://github.com/theoephraim/node-pg-migrate/pull/104) | ||
## [2.7.1] (2017-08-28) | ||
@@ -4,0 +10,0 @@ |
@@ -44,2 +44,6 @@ 'use strict'; | ||
var _triggers = require('./operations/triggers'); | ||
var triggers = _interopRequireWildcard(_triggers); | ||
var _other = require('./operations/other'); | ||
@@ -114,5 +118,9 @@ | ||
this.createFunction = wrap(functions.create(options.typeShorthands)); | ||
this.dropFunction = wrap(functions.drop); | ||
this.renameFunction = wrap(functions.rename); | ||
this.dropFunction = wrap(functions.drop(options.typeShorthands)); | ||
this.renameFunction = wrap(functions.rename(options.typeShorthands)); | ||
this.createTrigger = wrap(triggers.create(options.typeShorthands)); | ||
this.dropTrigger = wrap(triggers.drop); | ||
this.renameTrigger = wrap(triggers.rename); | ||
this.sql = wrap(other.sql); | ||
@@ -119,0 +127,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.undoRename = exports.rename = exports.create = exports.drop = undefined; | ||
exports.rename = exports.create = exports.drop = undefined; | ||
@@ -42,10 +42,12 @@ var _utils = require('../utils'); | ||
var drop = exports.drop = function drop(function_name) { | ||
var function_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var drop = exports.drop = function drop(type_shorthands) { | ||
return function (function_name) { | ||
var function_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
ifExists = _ref.ifExists, | ||
cascade = _ref.cascade; | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
ifExists = _ref.ifExists, | ||
cascade = _ref.cascade; | ||
return _utils.template`DROP FUNCTION${ifExists ? ' IF EXISTS' : ''} "${function_name}"${formatParams(function_params)}${cascade ? ' CASCADE' : ''};`; | ||
return _utils.template`DROP FUNCTION${ifExists ? ' IF EXISTS' : ''} "${function_name}"${formatParams(function_params, type_shorthands)}${cascade ? ' CASCADE' : ''};`; | ||
}; | ||
}; | ||
@@ -97,18 +99,20 @@ | ||
}; | ||
_create.reverse = drop; | ||
_create.reverse = drop(type_shorthands); | ||
return _create; | ||
}; | ||
var rename = exports.rename = function rename(old_function_name) { | ||
var function_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var new_function_name = arguments[2]; | ||
return _utils.template`ALTER FUNCTION "${old_function_name}"${formatParams(function_params)} RENAME TO "${new_function_name}";`; | ||
}; | ||
var rename = exports.rename = function rename(type_shorthands) { | ||
var _rename = function _rename(old_function_name) { | ||
var function_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var new_function_name = arguments[2]; | ||
return _utils.template`ALTER FUNCTION "${old_function_name}"${formatParams(function_params, type_shorthands)} RENAME TO "${new_function_name}";`; | ||
}; | ||
var undoRename = exports.undoRename = function undoRename(old_function_name) { | ||
var function_params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var new_function_name = arguments[2]; | ||
return rename(new_function_name, function_params, old_function_name); | ||
}; | ||
_rename.reverse = function (old_function_name, function_params, new_function_name) { | ||
return _rename(new_function_name, function_params, old_function_name); | ||
}; | ||
rename.reverse = undoRename; | ||
return _rename; | ||
}; |
@@ -22,3 +22,3 @@ { | ||
], | ||
"version": "2.7.1", | ||
"version": "2.8.0", | ||
"engines": { | ||
@@ -25,0 +25,0 @@ "node": ">=4.0.0" |
@@ -404,3 +404,3 @@ # pg-migrate | ||
> Alters a role - [postgres docs](http://www.postgresql.org/docs/current/static/sql-alterrole.html) | ||
> Renames a role - [postgres docs](http://www.postgresql.org/docs/current/static/sql-alterrole.html) | ||
@@ -430,6 +430,6 @@ **Arguments:** | ||
- `function_options` _[object]_ - options: | ||
- `returns` _[string]_ - returns clause | ||
- `language` _[string]_ - language name of function definition | ||
- `replace` _[boolean]_ - create or replace function | ||
- `returns` _[string]_ - returns clause | ||
- `delimiter` _[string]_ - delimiter for definition | ||
- `language` _[string]_ - language name of function definition | ||
- `window` _[boolean]_ - window function | ||
@@ -445,3 +445,3 @@ - `behavior` _[string]_ - `IMMUTABLE`, `STABLE`, or `VOLATILE` | ||
#### `pgm.dropFunction( function_name, function_params )` | ||
#### `pgm.dropFunction( function_name, function_params, drop_options )` | ||
@@ -451,4 +451,7 @@ > Drop a function - [postgres docs](http://www.postgresql.org/docs/current/static/sql-dropfunction.html) | ||
**Arguments:** | ||
- `function_name` _[string]_ - name of the new function | ||
- `function_name` _[string]_ - name of the the function to drop | ||
- `function_params` _[array]_ - [see](#pgmcreatefunction-function_name-function_params-function_options-definition-) | ||
- `drop_options` _[object]_ - options: | ||
- `ifExists` _[boolean]_ - drops function only if it exists | ||
- `cascade` _[boolean]_ - drops also dependent objects | ||
@@ -459,3 +462,3 @@ ----------------------------------------------------- | ||
> Alters a function - [postgres docs](http://www.postgresql.org/docs/current/static/sql-alterfunction.html) | ||
> Renames a function - [postgres docs](http://www.postgresql.org/docs/current/static/sql-alterfunction.html) | ||
@@ -469,2 +472,50 @@ **Arguments:** | ||
### Trigger Operations | ||
#### `pgm.createTrigger( table_name, trigger_name, trigger_options )` | ||
> Create a new function - [postgres docs](https://www.postgresql.org/docs/current/static/sql-createtrigger.html) | ||
**Arguments:** | ||
- `table_name` _[string]_ - name of the table where the new trigger will live | ||
- `trigger_name` _[string]_ - name of the new trigger | ||
- `trigger_options` _[object]_ - options: | ||
- `when` _[string]_ - `BEFORE`, `AFTER`, or `INSTEAD OF` | ||
- `operation` _[string or array]_ - `INSERT`, `UPDATE[ OF ...]`, `DELETE` or `TRUNCATE` | ||
- `constraint` _[boolean]_ - creates constraint trigger | ||
- `function` _[string]_ - the name of procedure to execute | ||
- `level` _[string]_ - `STATEMENT`, or `ROW` | ||
- `condition` _[string]_ - condition to met to execute trigger | ||
- `deferrable` _[boolean]_ - flag for deferrable constraint trigger | ||
- `deferred` _[boolean]_ - flag for initially deferred deferrable constraint trigger | ||
- `definition` _[string]_ - optional definition of function which will be created with same name as trigger | ||
**Reverse Operation:** `dropTrigger` | ||
----------------------------------------------------- | ||
#### `pgm.dropTrigger( table_name, trigger_name, drop_options )` | ||
> Drop a trigger - [postgres docs](http://www.postgresql.org/docs/current/static/sql-droptrigger.html) | ||
**Arguments:** | ||
- `table_name` _[string]_ - name of the table where the trigger lives | ||
- `trigger_name` _[string]_ - name of the the trigger to drop | ||
- `drop_options` _[object]_ - options: | ||
- `ifExists` _[boolean]_ - drops trigger only if it exists | ||
- `cascade` _[boolean]_ - drops also dependent objects | ||
----------------------------------------------------- | ||
#### `pgm.renameTrigger( table_name, old_trigger_name, new_trigger_name )` | ||
> Renames a trigger - [postgres docs](http://www.postgresql.org/docs/current/static/sql-altertrigger.html) | ||
**Arguments:** | ||
- `table_name` _[string]_ - name of the table where the trigger lives | ||
- `old_trigger_name` _[string]_ - old name of the trigger | ||
- `new_trigger_name` _[string]_ - new name of the trigger | ||
----------------------------------------------------- | ||
### Miscellaneous Operations | ||
@@ -471,0 +522,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176447
1111
589