Skip to content

Commit a93dd62

Browse files
committed
Fixed applySqlChanges and addForeignKeys to include options
1 parent 00c0397 commit a93dd62

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/migration.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function mixinMigration(PostgreSQL) {
161161
const action = actions.shift();
162162
const pendingChanges = action && action() || [];
163163
if (pendingChanges.length) {
164-
self.applySqlChanges(model, pendingChanges, function (err, result) {
164+
self.applySqlChanges(model, pendingChanges, options, function (err, result) {
165165
if (!err) {
166166
applyPending(actions, cb, err, result);
167167
} else {
@@ -201,7 +201,7 @@ function mixinMigration(PostgreSQL) {
201201
self.getModelDefinition(model).settings.foreignKeys,
202202
actualFks);
203203

204-
self.addForeignKeys(model, fkSQL, cb);
204+
self.addForeignKeys(model, fkSQL, options, cb);
205205
},
206206
], function (err, result) {
207207
cb(err, result[0]);
@@ -438,13 +438,15 @@ function mixinMigration(PostgreSQL) {
438438
createExtensions +
439439
'CREATE SCHEMA ' +
440440
self.escapeName(self.schema(model)),
441+
[],
441442
options,
442443
function (err) {
443444
if (err && err.code !== '42P06') {
444445
return cb && cb(err);
445446
}
446447
self.execute('CREATE TABLE ' + name + ' (\n ' +
447448
self.propertiesSQL(model) + '\n)',
449+
[],
448450
options,
449451
function (err, info) {
450452
if (err) {
@@ -456,7 +458,7 @@ function mixinMigration(PostgreSQL) {
456458
}
457459
const fkSQL = self.getForeignKeySQL(model,
458460
self.getModelDefinition(model).settings.foreignKeys);
459-
self.addForeignKeys(model, fkSQL, function (err, result) {
461+
self.addForeignKeys(model, fkSQL, options, function (err, result) {
460462
cb(err);
461463
});
462464
});
@@ -621,11 +623,17 @@ function mixinMigration(PostgreSQL) {
621623
}
622624
};
623625

624-
PostgreSQL.prototype.addForeignKeys = function (model, fkSQL, cb) {
626+
PostgreSQL.prototype.addForeignKeys = function (model, fkSQL, options, cb) {
625627
const self = this;
626628

629+
if ((!cb) && typeof options === 'function') {
630+
cb = options;
631+
options = {};
632+
}
633+
options = options || {};
634+
627635
if (fkSQL && fkSQL.length) {
628-
self.applySqlChanges(model, [fkSQL.toString()], function (err, result) {
636+
self.applySqlChanges(model, [fkSQL.toString()], options, function (err, result) {
629637
if (err) cb(err);
630638
else
631639
cb(null, result);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apexdesigner/loopback-connector-postgresql",
3-
"version": "7.0.7",
3+
"version": "7.0.8",
44
"description": "Loopback PostgreSQL Connector",
55
"keywords": [
66
"LoopBack",

0 commit comments

Comments
 (0)