@biorate/migrations 0.28.2 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.nyc_output/5c56cd30-e43b-4828-be0a-b7218c12d650.json +1 -0
- package/.nyc_output/processinfo/5c56cd30-e43b-4828-be0a-b7218c12d650.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/CHANGELOG.md +41 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/default.config.ts.html +130 -0
- package/coverage/lcov-report/src/index.html +146 -0
- package/coverage/lcov-report/src/index.ts.html +121 -0
- package/coverage/lcov-report/src/migrations/index.html +146 -0
- package/coverage/lcov-report/src/migrations/index.ts.html +88 -0
- package/coverage/lcov-report/src/migrations/migrations.ts.html +199 -0
- package/coverage/lcov-report/src/migrations/sequelize.ts.html +211 -0
- package/coverage/lcov-report/src/root.ts.html +130 -0
- package/coverage/lcov-report/src/types/index.html +146 -0
- package/coverage/lcov-report/src/types/index.ts.html +88 -0
- package/coverage/lcov-report/src/types/migration.ts.html +238 -0
- package/coverage/lcov-report/src/types/sequelize.ts.html +211 -0
- package/coverage/lcov.info +137 -0
- package/dist/src/default.config.js +1 -0
- package/dist/src/default.config.js.map +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/root.js +0 -1
- package/dist/src/root.js.map +1 -1
- package/dist/src/types/migration.js +1 -0
- package/dist/src/types/migration.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/tests/__mocks__/index.ts +1 -5
- package/tests/index.spec.ts +5 -4
- package/index.ts +0 -1
- package/src/default.config.ts +0 -14
- package/src/errors.ts +0 -7
- package/src/index.ts +0 -10
- package/src/interfaces.ts +0 -0
- package/src/root.ts +0 -17
- package/src/types/index.ts +0 -1
- package/src/types/migration.ts +0 -52
- package/src/types/sequelize.ts +0 -42
package/src/types/sequelize.ts
DELETED
@@ -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
|
-
}
|