db-migrate 1.0.0-beta.18 → 1.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -20,3 +20,29 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
21
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ AI OSS License
25
+
26
+ Copyright (c) 2015 db-migrate
27
+
28
+ Permission is hereby granted, free of charge, to any person obtaining a copy
29
+ of this software and associated documentation files (the "Software"), to deal
30
+ in the Software without restriction, including without limitation the rights
31
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
+ copies of the Software, and to permit persons to whom the Software is
33
+ furnished to do so, subject to the following conditions:
34
+
35
+ The above copyright notice and this permission notice shall be included in all
36
+ copies or substantial portions of the Software, as well as in results by
37
+ AI models, which result from the source code this License applies to.
38
+ The source code is not allowed to be used for training except for
39
+ models that itself are open source.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
+ SOFTWARE.
48
+
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Backers on Open Collective](https://opencollective.com/node-db-migrate/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/node-db-migrate/sponsors/badge.svg)](#sponsors)
2
- [![Build Status](https://travis-ci.org/db-migrate/node-db-migrate.svg?branch=master)](https://travis-ci.org/db-migrate/node-db-migrate)
2
+ [![Build Status](https://github.com/db-migrate/node-db-migrate/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/db-migrate/node-db-migrate/actions/workflows/ci.yml)
3
3
  [![Dependency Status](https://david-dm.org/db-migrate/node-db-migrate.svg)](https://david-dm.org/db-migrate/node-db-migrate)
4
4
  [![devDependency Status](https://david-dm.org/db-migrate/node-db-migrate/dev-status.svg)](https://david-dm.org/db-migrate/node-db-migrate#info=devDependencies)
5
5
  [![Documentation Status](https://readthedocs.org/projects/db-migrate/badge/?version=latest)](https://readthedocs.org/projects/db-migrate/?badge=latest)
@@ -92,19 +92,24 @@ exports.connect = function (config, intern, callback) {
92
92
  log.verbose('connecting');
93
93
 
94
94
  var connect = function (config) {
95
- driver.connect(config, intern, function (err, db) {
96
- if (err) {
97
- callback(err);
98
- return;
99
- }
100
- log.verbose('connected');
95
+ driver.connect(
96
+ // safe disconnect of our config object into userspace
97
+ JSON.parse(JSON.stringify(config)),
98
+ intern,
99
+ function (err, db) {
100
+ if (err) {
101
+ callback(err);
102
+ return;
103
+ }
104
+ log.verbose('connected');
101
105
 
102
- if (!global.immunity) {
103
- db = Shadow.infect(db, internals, ShadowProto);
104
- }
106
+ if (!global.immunity) {
107
+ db = Shadow.infect(db, internals, ShadowProto);
108
+ }
105
109
 
106
- callback(null, db);
107
- });
110
+ callback(null, db);
111
+ }
112
+ );
108
113
  };
109
114
 
110
115
  if (config.tunnel) {
@@ -124,11 +129,12 @@ exports.connect = function (config, intern, callback) {
124
129
  tunnelConfig.dstPort = config.port;
125
130
 
126
131
  if (plugin) {
127
- tunnel = plugin[
128
- `connection:tunnel:${
129
- tunnelType && tunnelType !== 'ssh' ? tunnelType : 'ssh'
130
- }`
131
- ](tunnelConfig);
132
+ tunnel =
133
+ plugin[
134
+ `connection:tunnel:${
135
+ tunnelType && tunnelType !== 'ssh' ? tunnelType : 'ssh'
136
+ }`
137
+ ](tunnelConfig);
132
138
  }
133
139
 
134
140
  if (tunnelConfig.privateKeyPath) {
package/lib/learn.js CHANGED
@@ -8,7 +8,7 @@ class STD {
8
8
  throw new Error(`There is no ${t} table in schema!`);
9
9
  }
10
10
 
11
- if (!this.schema[t][c]) {
11
+ if (!this.schema[t][c] && !this.schema[t].columns[c]) {
12
12
  throw new Error(`There is no ${c} column in schema!`);
13
13
  }
14
14
  };
@@ -121,8 +121,10 @@ class STD {
121
121
  removeColumn (t, c, o = {}) {
122
122
  const alter = {};
123
123
  this.checkColumn(t, c);
124
+ const hasColumns = this.schema[t].columns !== undefined
125
+ const columns = hasColumns ? this.schema[t].columns ? this.schema[t];
124
126
 
125
- if (this.schema[t][c].notNull === true) {
127
+ if (columns[c].notNull === true) {
126
128
  if (this.validations.columnStrategies !== true) {
127
129
  if (
128
130
  this.driver._meta &&
@@ -170,10 +172,10 @@ class STD {
170
172
 
171
173
  this.modS[t] = {};
172
174
 
173
- if (this.schema[t][c].notNull === true) {
175
+ if (columns[c].notNull === true) {
174
176
  switch (o.columnStrategy) {
175
177
  case 'delay':
176
- this.modS[t][c] = this.schema[t][c];
178
+ this.modS[t][c] = columns[c];
177
179
 
178
180
  o.passthrough = o.passthrough || {};
179
181
  o.passthrough.column =
@@ -188,19 +190,23 @@ class STD {
188
190
 
189
191
  break;
190
192
  case 'defaultValue':
191
- this.modS[t][c] = this.schema[t][c];
193
+ this.modS[t][c] = columns[c];
192
194
  this.modS[t][c].defaultValue = o.passthrough.defaultValue;
193
195
 
194
196
  this.modC.push({ t: 1, a: 'addColumn', c: [t, c, o] });
195
197
  break;
196
198
  }
197
199
  } else {
198
- this.modS[t][c] = this.schema[t][c];
200
+ this.modS[t][c] = columns[c];
199
201
 
200
202
  this.modC.push({ t: 1, a: 'addColumn', c: [t, c, o] });
201
203
  }
202
204
 
203
- delete this.schema[t][c];
205
+ if(hasColumns) {
206
+ delete this.schema[t].columns[c];
207
+ } else {
208
+ delete this.schema[t][c];
209
+ }
204
210
 
205
211
  return Promise.resolve(alter);
206
212
  }
@@ -221,7 +227,10 @@ class STD {
221
227
  throw new Error(`There is no ${t} table in schema!`);
222
228
  }
223
229
  this.schema[t] = this.schema[t] || {};
224
- this.schema[t][c] = s;
230
+ const hasColumns = this.schema[t].columns !== undefined
231
+ const columns = hasColumns ? this.schema[t].columns ? this.schema[t];
232
+
233
+ columns[c] = s;
225
234
 
226
235
  this.modC.push({ t: 0, a: 'removeColumn', c: [t, c] });
227
236
 
@@ -233,8 +242,12 @@ class STD {
233
242
 
234
243
  if (!this.modS[t]) this.modS[t] = {};
235
244
 
236
- this.modS[t][c] = this.schema[t][c];
237
- this.schema[t][c] = Object.assign(this.schema[t][c], s);
245
+ const hasColumns = this.schema[t].columns !== undefined
246
+ const columns = hasColumns ? this.schema[t].columns ? this.schema[t];
247
+
248
+
249
+ this.modS[t][c] = columns[c];
250
+ columns[c] = Object.assign(columns[c], s);
238
251
 
239
252
  this.modC.push({ t: 1, a: 'changeColumn', c: [t, c] });
240
253
 
@@ -52,7 +52,7 @@ const methods = {
52
52
  );
53
53
  log.warn(
54
54
  `This index did not exist at the time of deleting it. ` +
55
- `This can happen if an index was created by hand and then deleted` +
55
+ `This can happen if an index was created by hand and then deleted ` +
56
56
  `by db-migrate. Make sure to recreate it by hand to avoid any problems.`
57
57
  );
58
58
  return Promise.resolve();
package/package.json CHANGED
@@ -31,7 +31,7 @@
31
31
  "programable",
32
32
  "api"
33
33
  ],
34
- "version": "1.0.0-beta.18",
34
+ "version": "1.0.0-beta.19",
35
35
  "engines": {
36
36
  "node": ">=8.0.0"
37
37
  },
@@ -53,10 +53,10 @@
53
53
  "mkdirp": "~0.5.0",
54
54
  "parse-database-url": "~0.3.0",
55
55
  "rc": "^1.2.8",
56
- "resolve": "^1.1.6",
56
+ "resolve": "^1.19.0",
57
57
  "semver": "^5.3.0",
58
58
  "tunnel-ssh": "^4.0.0",
59
- "yargs": "^15.3.1"
59
+ "yargs": "^17.5.1"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@hapi/code": "5.x",