@riao/dbal 3.7.1 → 3.8.0

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.
@@ -1,2 +1,3 @@
1
1
  export { MigrationRunner } from './migration-runner';
2
2
  export { Migration } from './migration';
3
+ export { MigrationPackage, PackagedMigrations } from './migration-package';
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Migration = exports.MigrationRunner = void 0;
3
+ exports.MigrationPackage = exports.Migration = exports.MigrationRunner = void 0;
4
4
  var migration_runner_1 = require("./migration-runner");
5
5
  Object.defineProperty(exports, "MigrationRunner", { enumerable: true, get: function () { return migration_runner_1.MigrationRunner; } });
6
6
  var migration_1 = require("./migration");
7
7
  Object.defineProperty(exports, "Migration", { enumerable: true, get: function () { return migration_1.Migration; } });
8
+ var migration_package_1 = require("./migration-package");
9
+ Object.defineProperty(exports, "MigrationPackage", { enumerable: true, get: function () { return migration_package_1.MigrationPackage; } });
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migration/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/migration/index.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,yDAA2E;AAAlE,qHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { Migration } from './migration';
2
+ export type PackagedMigrations = Record<string, typeof Migration>;
3
+ /**
4
+ * Create migration packages that can bundle multiple migrations together.
5
+ * Useful for libraries that want to distribute migrations with their package.
6
+ */
7
+ export declare abstract class MigrationPackage {
8
+ /** The name of the package, used for logging */
9
+ abstract name: string;
10
+ /** The package identifier, used for storing migration records */
11
+ abstract package: string;
12
+ /** Override to provide the migrations included in this package */
13
+ abstract getMigrations(): Promise<PackagedMigrations>;
14
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MigrationPackage = void 0;
4
+ /**
5
+ * Create migration packages that can bundle multiple migrations together.
6
+ * Useful for libraries that want to distribute migrations with their package.
7
+ */
8
+ class MigrationPackage {
9
+ }
10
+ exports.MigrationPackage = MigrationPackage;
11
+ //# sourceMappingURL=migration-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-package.js","sourceRoot":"","sources":["../../../src/migration/migration-package.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACH,MAAsB,gBAAgB;CASrC;AATD,4CASC"}
@@ -5,5 +5,6 @@ import { DatabaseRecordId } from '../record';
5
5
  export interface MigrationRecord {
6
6
  id: DatabaseRecordId;
7
7
  name: string;
8
+ package: string | null;
8
9
  timestamp: string;
9
10
  }
@@ -1,5 +1,6 @@
1
1
  import { Database } from '../database';
2
2
  import { Migration } from './migration';
3
+ import { MigrationPackage } from './migration-package';
3
4
  /**
4
5
  * Runs migrations
5
6
  */
@@ -8,6 +9,8 @@ export declare class MigrationRunner {
8
9
  constructor(db: Database);
9
10
  /**
10
11
  * Run migrations
12
+ * @deprecated This method will change parameters in a future release.
13
+ * Switch to runWithOptions() to prepare for this change.
11
14
  *
12
15
  * @param migrations (Optional) Folder to find migrations in. Default is
13
16
  * db.getMigraitonDirectory()
@@ -15,8 +18,16 @@ export declare class MigrationRunner {
15
18
  * @param direction (Optional) Run migrations up or down?
16
19
  * @param steps (Optional) Run a certain number of steps?
17
20
  */
18
- run(migrations?: string | Record<string, Migration>, log?: (...args: any[]) => void, direction?: 'up' | 'down', steps?: number): Promise<void>;
21
+ run(migrations?: string | Record<string, Migration | MigrationPackage>, log?: (...args: any[]) => void, direction?: 'up' | 'down', steps?: number): Promise<void>;
22
+ runWithOptions(options: {
23
+ migrations?: string | Record<string, Migration | MigrationPackage>;
24
+ log?: (...args: any[]) => void;
25
+ direction?: 'up' | 'down';
26
+ steps?: number;
27
+ package?: string;
28
+ }): Promise<void>;
19
29
  protected getMigrationName(filename: string): string;
20
30
  protected loadMigration(dir: string, filename: string): Migration;
21
31
  protected loadMigrationsFromDirectory(dir: string): Record<string, Migration>;
32
+ protected runRiaoDbalMigrations(): Promise<void>;
22
33
  }
@@ -13,7 +13,9 @@ exports.MigrationRunner = void 0;
13
13
  const fs = require("fs");
14
14
  const path_1 = require("path");
15
15
  const ts_import_ts_1 = require("ts-import-ts");
16
- const create_migration_table_1 = require("./create-migration-table");
16
+ const _001_create_migration_table_1 = require("./migrations/001-create-migration-table");
17
+ const migration_package_1 = require("./migration-package");
18
+ const _002_add_migration_package_column_1 = require("./migrations/002-add-migration-package-column");
17
19
  /**
18
20
  * Runs migrations
19
21
  */
@@ -23,6 +25,8 @@ class MigrationRunner {
23
25
  }
24
26
  /**
25
27
  * Run migrations
28
+ * @deprecated This method will change parameters in a future release.
29
+ * Switch to runWithOptions() to prepare for this change.
26
30
  *
27
31
  * @param migrations (Optional) Folder to find migrations in. Default is
28
32
  * db.getMigraitonDirectory()
@@ -34,9 +38,26 @@ class MigrationRunner {
34
38
  /* eslint-disable-next-line no-console */
35
39
  log = console.log, direction = 'up', steps) {
36
40
  return __awaiter(this, void 0, void 0, function* () {
37
- if (!migrations) {
38
- migrations = this.db.getMigrationsDirectory();
39
- }
41
+ return yield this.runWithOptions({
42
+ migrations,
43
+ log,
44
+ direction,
45
+ steps,
46
+ });
47
+ });
48
+ }
49
+ runWithOptions(options) {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const name = options.package || this.db.name || 'database';
52
+ let migrations = options.migrations || this.db.getMigrationsDirectory();
53
+ // eslint-disable-next-line no-console
54
+ const optionsLog = options.log || console.log;
55
+ const log = (...args) => {
56
+ optionsLog(`[${name}]\t`, ...args);
57
+ };
58
+ const direction = options.direction || 'up';
59
+ let steps = options.steps;
60
+ const pkg = options.package || null;
40
61
  if (steps === -1) {
41
62
  steps = undefined;
42
63
  }
@@ -44,13 +65,13 @@ class MigrationRunner {
44
65
  throw new Error('Steps must be a positive integer, or -1 for all.');
45
66
  }
46
67
  // Create migration table, if not existing
47
- const createMigrationTable = new create_migration_table_1.CreateMigrationTable(this.db);
48
- yield createMigrationTable.up();
68
+ yield this.runRiaoDbalMigrations();
49
69
  // Query migrations that have already run
50
70
  const repo = this.db.getQueryRepository();
51
71
  const alreadyRanMigrations = yield repo.find({
52
72
  columns: ['name'],
53
73
  table: 'riao_migration',
74
+ where: { package: pkg ? pkg : null },
54
75
  });
55
76
  const alreadyRanNames = alreadyRanMigrations.map((migration) => migration.name);
56
77
  if (typeof migrations === 'string') {
@@ -85,18 +106,31 @@ class MigrationRunner {
85
106
  // Run the migration
86
107
  log(direction.toLocaleUpperCase() + ' | ', name);
87
108
  const migration = migrations[name];
109
+ if (migration instanceof migration_package_1.MigrationPackage) {
110
+ log('Importing packaged migrations for ' +
111
+ migration.name +
112
+ '...');
113
+ const importedMigrationTypes = yield migration.getMigrations();
114
+ const PackagedMigrations = Object.keys(importedMigrationTypes).reduce((obj, key) => {
115
+ const migrationType = importedMigrationTypes[key];
116
+ obj[key] = new migrationType(this.db);
117
+ return obj;
118
+ }, {});
119
+ yield this.runWithOptions(Object.assign(Object.assign({}, options), { steps: undefined, migrations: PackagedMigrations, package: migration.package }));
120
+ continue;
121
+ }
88
122
  yield migration[direction]();
89
123
  // Save the migration record
90
124
  if (direction === 'up') {
91
125
  yield repo.insert({
92
126
  table: 'riao_migration',
93
- records: { name },
127
+ records: { name, package: pkg ? pkg : null },
94
128
  });
95
129
  }
96
130
  else {
97
131
  yield repo.delete({
98
132
  table: 'riao_migration',
99
- where: { name },
133
+ where: { name, package: pkg ? pkg : null },
100
134
  });
101
135
  }
102
136
  }
@@ -127,6 +161,21 @@ class MigrationRunner {
127
161
  return obj;
128
162
  }, {});
129
163
  }
164
+ runRiaoDbalMigrations() {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ // Create table, if not existing
167
+ const createMigrationTable = new _001_create_migration_table_1.CreateMigrationTable(this.db);
168
+ yield createMigrationTable.up();
169
+ // Check if `package` column exists, and if not, add it
170
+ const columns = yield this.db
171
+ .getSchemaQueryRepository()
172
+ .getColumns({ table: 'riao_migration' });
173
+ if (!columns.find((col) => col.name === 'package')) {
174
+ const addMigrationPackageColumn = new _002_add_migration_package_column_1.AddMigrationPackageColumn(this.db);
175
+ yield addMigrationPackageColumn.up();
176
+ }
177
+ });
178
+ }
130
179
  }
131
180
  exports.MigrationRunner = MigrationRunner;
132
181
  //# sourceMappingURL=migration-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-runner.js","sourceRoot":"","sources":["../../../src/migration/migration-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yBAAyB;AACzB,+BAA2D;AAC3D,+CAAwC;AAGxC,qEAAgE;AAIhE;;GAEG;AACH,MAAa,eAAe;IAG3B,YAAmB,EAAY;QAC9B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACU,GAAG,CACf,UAA+C;IAC/C,yCAAyC;IACzC,MAAgC,OAAO,CAAC,GAAG,EAC3C,YAA2B,IAAI,EAC/B,KAAc;;YAEd,IAAI,CAAC,UAAU,EAAE;gBAChB,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,sBAAsB,EAAE,CAAC;aAC9C;YAED,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBACjB,KAAK,GAAG,SAAS,CAAC;aAClB;YAED,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC,EAAE;gBACrC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;aACpE;YAED,0CAA0C;YAC1C,MAAM,oBAAoB,GAAG,IAAI,6CAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAA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U,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAE1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,EAAE;gBACnD,MAAM,yBAAyB,GAAG,IAAI,6DAAyB,CAC9D,IAAI,CAAC,EAAE,CACP,CAAC;gBAEF,MAAM,yBAAyB,CAAC,EAAE,EAAE,CAAC;aACrC;QACF,CAAC;KAAA;CACD;AA9ND,0CA8NC"}
@@ -1,4 +1,4 @@
1
- import { Migration } from './migration';
1
+ import { Migration } from './../migration';
2
2
  /**
3
3
  * Create a migration table to track current-state
4
4
  */
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CreateMigrationTable = void 0;
13
- const column_1 = require("../column");
14
- const functions_1 = require("../functions");
15
- const migration_1 = require("./migration");
13
+ const column_1 = require("../../column");
14
+ const functions_1 = require("../../functions");
15
+ const migration_1 = require("./../migration");
16
16
  /**
17
17
  * Create a migration table to track current-state
18
18
  */
@@ -52,4 +52,4 @@ class CreateMigrationTable extends migration_1.Migration {
52
52
  }
53
53
  }
54
54
  exports.CreateMigrationTable = CreateMigrationTable;
55
- //# sourceMappingURL=create-migration-table.js.map
55
+ //# sourceMappingURL=001-create-migration-table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"001-create-migration-table.js","sourceRoot":"","sources":["../../../../src/migration/migrations/001-create-migration-table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA0C;AAC1C,+CAAoD;AACpD,8CAA2C;AAE3C;;GAEG;AACH,MAAa,oBAAqB,SAAQ,qBAAS;IAC5B,EAAE;;YACvB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC1B,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,IAAI;wBACV,IAAI,EAAE,mBAAU,CAAC,GAAG;wBACpB,aAAa,EAAE,IAAI;wBACnB,UAAU,EAAE,IAAI;qBAChB;oBACD;wBACC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mBAAU,CAAC,OAAO;wBACxB,MAAM,EAAE,GAAG;qBACX;oBACD;wBACC,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,mBAAU,CAAC,SAAS;wBAC1B,OAAO,EAAE,6BAAiB,CAAC,gBAAgB,EAAE;qBAC7C;iBACD;aACD,CAAC,CAAC;QACJ,CAAC;KAAA;IAEqB,IAAI;;YACzB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;gBACxB,MAAM,EAAE,gBAAgB;aACxB,CAAC,CAAC;QACJ,CAAC;KAAA;CACD;AA/BD,oDA+BC"}
@@ -0,0 +1,9 @@
1
+ import { Migration } from './../migration';
2
+ /**
3
+ * Add a migration package column to the migration table so that
4
+ * migrations can be scoped by package
5
+ */
6
+ export declare class AddMigrationPackageColumn extends Migration {
7
+ up(): Promise<void>;
8
+ down(): Promise<void>;
9
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AddMigrationPackageColumn = void 0;
13
+ const column_1 = require("../../column");
14
+ const migration_1 = require("./../migration");
15
+ /**
16
+ * Add a migration package column to the migration table so that
17
+ * migrations can be scoped by package
18
+ */
19
+ class AddMigrationPackageColumn extends migration_1.Migration {
20
+ up() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ yield this.ddl.addColumns({
23
+ table: 'riao_migration',
24
+ columns: [
25
+ {
26
+ name: 'package',
27
+ type: column_1.ColumnType.VARCHAR,
28
+ length: 255,
29
+ default: null,
30
+ },
31
+ ],
32
+ });
33
+ });
34
+ }
35
+ down() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ yield this.ddl.dropColumn({
38
+ table: 'riao_migration',
39
+ column: 'package',
40
+ });
41
+ });
42
+ }
43
+ }
44
+ exports.AddMigrationPackageColumn = AddMigrationPackageColumn;
45
+ //# sourceMappingURL=002-add-migration-package-column.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"002-add-migration-package-column.js","sourceRoot":"","sources":["../../../../src/migration/migrations/002-add-migration-package-column.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA0C;AAC1C,8CAA2C;AAE3C;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,qBAAS;IACjC,EAAE;;YACvB,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;gBACzB,KAAK,EAAE,gBAAgB;gBACvB,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,mBAAU,CAAC,OAAO;wBACxB,MAAM,EAAE,GAAG;wBACX,OAAO,EAAE,IAAI;qBACb;iBACD;aACD,CAAC,CAAC;QACJ,CAAC;KAAA;IAEqB,IAAI;;YACzB,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;gBACzB,KAAK,EAAE,gBAAgB;gBACvB,MAAM,EAAE,SAAS;aACjB,CAAC,CAAC;QACJ,CAAC;KAAA;CACD;AArBD,8DAqBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riao/dbal",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "description": "riao database",
5
5
  "typescript-template": {
6
6
  "base": "1.0.0",
@@ -1,2 +0,0 @@
1
- import { ColumnOptions } from '../../column';
2
- export declare const LoginColumn: ColumnOptions;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoginColumn = void 0;
4
- const column_1 = require("../../column");
5
- exports.LoginColumn = {
6
- name: 'login',
7
- type: column_1.ColumnType.VARCHAR,
8
- length: 64,
9
- isUnique: true,
10
- required: true,
11
- };
12
- //# sourceMappingURL=login-column.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login-column.js","sourceRoot":"","sources":["../../../../src/column-pack/user/login-column.ts"],"names":[],"mappings":";;;AAAA,yCAAyD;AAE5C,QAAA,WAAW,GAAkB;IACzC,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,mBAAU,CAAC,OAAO;IACxB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;CACd,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-migration-table.js","sourceRoot":"","sources":["../../../src/migration/create-migration-table.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAuC;AACvC,4CAAiD;AACjD,2CAAwC;AAExC;;GAEG;AACH,MAAa,oBAAqB,SAAQ,qBAAS;IAC5B,EAAE;;YACvB,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC1B,IAAI,EAAE,gBAAgB;gBACtB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,IAAI;wBACV,IAAI,EAAE,mBAAU,CAAC,GAAG;wBACpB,aAAa,EAAE,IAAI;wBACnB,UAAU,EAAE,IAAI;qBAChB;oBACD;wBACC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,mBAAU,CAAC,OAAO;wBACxB,MAAM,EAAE,GAAG;qBACX;oBACD;wBACC,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,mBAAU,CAAC,SAAS;wBAC1B,OAAO,EAAE,6BAAiB,CAAC,gBAAgB,EAAE;qBAC7C;iBACD;aACD,CAAC,CAAC;QACJ,CAAC;KAAA;IAEqB,IAAI;;YACzB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;gBACxB,MAAM,EAAE,gBAAgB;aACxB,CAAC,CAAC;QACJ,CAAC;KAAA;CACD;AA/BD,oDA+BC"}