@biorate/migrations 0.28.2 → 0.30.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.
Files changed (46) hide show
  1. package/.nyc_output/5c56cd30-e43b-4828-be0a-b7218c12d650.json +1 -0
  2. package/.nyc_output/processinfo/5c56cd30-e43b-4828-be0a-b7218c12d650.json +1 -0
  3. package/.nyc_output/processinfo/index.json +1 -0
  4. package/CHANGELOG.md +41 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +131 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov-report/src/default.config.ts.html +130 -0
  14. package/coverage/lcov-report/src/index.html +146 -0
  15. package/coverage/lcov-report/src/index.ts.html +121 -0
  16. package/coverage/lcov-report/src/migrations/index.html +146 -0
  17. package/coverage/lcov-report/src/migrations/index.ts.html +88 -0
  18. package/coverage/lcov-report/src/migrations/migrations.ts.html +199 -0
  19. package/coverage/lcov-report/src/migrations/sequelize.ts.html +211 -0
  20. package/coverage/lcov-report/src/root.ts.html +130 -0
  21. package/coverage/lcov-report/src/types/index.html +146 -0
  22. package/coverage/lcov-report/src/types/index.ts.html +88 -0
  23. package/coverage/lcov-report/src/types/migration.ts.html +238 -0
  24. package/coverage/lcov-report/src/types/sequelize.ts.html +211 -0
  25. package/coverage/lcov.info +137 -0
  26. package/dist/src/default.config.js +1 -0
  27. package/dist/src/default.config.js.map +1 -1
  28. package/dist/src/index.js +3 -3
  29. package/dist/src/index.js.map +1 -1
  30. package/dist/src/root.js +0 -1
  31. package/dist/src/root.js.map +1 -1
  32. package/dist/src/types/migration.js +1 -0
  33. package/dist/src/types/migration.js.map +1 -1
  34. package/dist/tsconfig.build.tsbuildinfo +1 -1
  35. package/package.json +8 -8
  36. package/tests/__mocks__/index.ts +1 -5
  37. package/tests/index.spec.ts +5 -4
  38. package/index.ts +0 -1
  39. package/src/default.config.ts +0 -14
  40. package/src/errors.ts +0 -7
  41. package/src/index.ts +0 -10
  42. package/src/interfaces.ts +0 -0
  43. package/src/root.ts +0 -17
  44. package/src/types/index.ts +0 -1
  45. package/src/types/migration.ts +0 -52
  46. package/src/types/sequelize.ts +0 -42
@@ -1,42 +0,0 @@
1
- import { promises as fs } from 'fs';
2
- import { path } from '@biorate/tools';
3
- import { Migration } from './migration';
4
- import { ISequelizeConnector, ISequelizeConfig, DataType } from '@biorate/sequelize';
5
- import { inject, Types } from '@biorate/inversion';
6
- /**
7
- * @description Sequelize migration class
8
- */
9
- export class Sequelize extends Migration {
10
- @inject(Types.Sequelize) protected sequelize: ISequelizeConnector;
11
- /**
12
- * @description Sequelize process method realization
13
- */
14
- protected async process() {
15
- for (const config of this.config.get<ISequelizeConfig[]>('Sequelize', [])) {
16
- const paths = await this.scan(config.name);
17
- if (!paths.length) continue;
18
- const connection = this.sequelize.connection(config.name);
19
- const model = connection.define(
20
- this.config.get<string>('migrations.tableName', 'migrations'),
21
- {
22
- name: {
23
- type: DataType.CHAR,
24
- primaryKey: true,
25
- },
26
- },
27
- { timestamps: false },
28
- );
29
- await model.sync({});
30
- for (const p of paths) {
31
- const name = path.basename(p);
32
- await connection.transaction(async () => {
33
- const item = await model.findOne({ where: { name } });
34
- if (item) return;
35
- await connection.query(await fs.readFile(p, 'utf8'));
36
- await model.create({ name });
37
- this.log(config.name, name);
38
- });
39
- }
40
- }
41
- }
42
- }