db-migrate 1.0.0-beta.21 → 1.0.0-beta.22

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/README.md CHANGED
@@ -1,10 +1,6 @@
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
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
- [![Dependency Status](https://david-dm.org/db-migrate/node-db-migrate.svg)](https://david-dm.org/db-migrate/node-db-migrate)
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
3
  [![Documentation Status](https://readthedocs.org/projects/db-migrate/badge/?version=latest)](https://readthedocs.org/projects/db-migrate/?badge=latest)
6
- [![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/db-migrate/node-db-migrate.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/db-migrate/node-db-migrate/context:javascript)
7
- [![Total Alerts](https://img.shields.io/lgtm/alerts/g/db-migrate/node-db-migrate.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/db-migrate/node-db-migrate/alerts)
8
4
 
9
5
  # db-migrate
10
6
 
package/lib/learn.js CHANGED
@@ -2,7 +2,7 @@ const Promise = require('bluebird');
2
2
  const Shadow = require('./driver/shadow');
3
3
 
4
4
  class STD {
5
- constructor ({ schema, modSchema: mod }, driver) {
5
+ constructor ({ schema, modSchema: mod, unlearn }, driver) {
6
6
  this.checkColumn = function (t, c) {
7
7
  if (!this.schema[t]) {
8
8
  throw new Error(`There is no ${t} table in schema!`);
@@ -12,6 +12,7 @@ class STD {
12
12
  throw new Error(`There is no ${c} column in schema!`);
13
13
  }
14
14
  };
15
+ this.unlearn = unlearn;
15
16
  this.validations = {};
16
17
  this.driver = driver;
17
18
  this.indizies = schema.i;
@@ -21,10 +22,14 @@ class STD {
21
22
  schema.e = {};
22
23
  }
23
24
  this.extra = schema.e;
25
+ if (unlearn) {
26
+ this.modC = [];
27
+ } else {
28
+ this.modC = mod.s;
29
+ }
24
30
  this.modS = mod.c;
25
31
  this.modI = mod.i;
26
32
  this.modF = mod.f;
27
- this.modC = mod.s;
28
33
  }
29
34
 
30
35
  dropTable (t) {
@@ -124,7 +129,7 @@ class STD {
124
129
  const hasColumns = this.schema[t].columns !== undefined;
125
130
  const columns = hasColumns ? this.schema[t].columns : this.schema[t];
126
131
 
127
- if (columns[c].notNull === true) {
132
+ if (columns[c].notNull === true && !this.unlearn) {
128
133
  if (this.validations.columnStrategies !== true) {
129
134
  if (
130
135
  this.driver._meta &&
@@ -172,7 +177,7 @@ class STD {
172
177
 
173
178
  this.modS[t] = {};
174
179
 
175
- if (columns[c].notNull === true) {
180
+ if (columns[c].notNull === true && !this.unlearn) {
176
181
  switch (o.columnStrategy) {
177
182
  case 'delay':
178
183
  this.modS[t][c] = columns[c];
@@ -196,7 +201,7 @@ class STD {
196
201
  this.modC.push({ t: 1, a: 'addColumn', c: [t, c, o] });
197
202
  break;
198
203
  }
199
- } else {
204
+ } else if (!this.unlearn) {
200
205
  this.modS[t][c] = columns[c];
201
206
 
202
207
  this.modC.push({ t: 1, a: 'addColumn', c: [t, c, o] });
@@ -2,6 +2,7 @@ const Promise = require('bluebird');
2
2
  const State = require('../../state');
3
3
  const Chain = require('../../chain');
4
4
  const Migrate = require('./migrate');
5
+ const Learn = require('../../learn');
5
6
  const log = require('db-migrate-shared').log;
6
7
 
7
8
  const methods = {
@@ -107,7 +108,9 @@ module.exports = async (context, file, driver, internals) => {
107
108
  const mod = internals.modSchema;
108
109
 
109
110
  const chain = new Chain(context, file, driver, internals);
110
- // chain.addChain(Learn);
111
+ internals.unlearn = true;
112
+
113
+ chain.addChain(Learn);
111
114
  chain.addChain(Migrate);
112
115
  await Promise.resolve(mod.s.reverse()).each(args =>
113
116
  processEntry(context, file, chain, internals, args)
package/package.json CHANGED
@@ -31,7 +31,7 @@
31
31
  "programable",
32
32
  "api"
33
33
  ],
34
- "version": "1.0.0-beta.21",
34
+ "version": "1.0.0-beta.22",
35
35
  "engines": {
36
36
  "node": ">=8.0.0"
37
37
  },
@@ -54,7 +54,6 @@
54
54
  "parse-database-url": "~0.3.0",
55
55
  "rc": "^1.2.8",
56
56
  "resolve": "^1.19.0",
57
- "semver": "^5.3.0",
58
57
  "tunnel-ssh": "^4.0.0",
59
58
  "yargs": "^17.5.1"
60
59
  },
@@ -64,8 +63,8 @@
64
63
  "@hapi/eslint-plugin": "^6.0.0",
65
64
  "@hapi/lab": "25.x",
66
65
  "db-migrate-base": "^2.1.1",
67
- "db-migrate-mysql": "^2.1.1",
68
- "db-migrate-sqlite3": "^0.4.0",
66
+ "db-migrate-mysql": "^2.2.0",
67
+ "db-migrate-sqlite3": "^0.5.0",
69
68
  "eslint": "^7.32.0",
70
69
  "eslint-config-standard": "^14.1.1",
71
70
  "eslint-plugin-import": "^2.26.0",