@ainias42/typeorm-helper 0.0.5 → 0.0.6
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/.eslintrc.cjs +1 -1
- package/.prettierrc +1 -1
- package/dist/BaseModel.d.ts +4 -4
- package/dist/BaseModel.js +6 -1
- package/dist/BaseModel.js.map +1 -1
- package/dist/DbNamingStrategy.d.ts +2 -2
- package/dist/DbNamingStrategy.js +9 -9
- package/dist/DbNamingStrategy.js.map +1 -1
- package/dist/DefaultSubscriber.d.ts +2 -2
- package/dist/DefaultSubscriber.js +7 -7
- package/dist/DefaultSubscriber.js.map +1 -1
- package/dist/dataSource/dataSource.d.ts +2 -2
- package/dist/dataSource/dataSource.js +1 -1
- package/dist/dataSource/getRepository.d.ts +3 -3
- package/dist/decorators/FileColumn/FileColumn.js +5 -5
- package/dist/decorators/FileColumn/FileTransformer.d.ts +1 -1
- package/dist/decorators/FileColumn/FileWriter.js +4 -1
- package/dist/decorators/FileColumn/FileWriter.js.map +1 -1
- package/dist/migration/getCreateTableColumns.js +15 -9
- package/dist/migration/getCreateTableColumns.js.map +1 -1
- package/dist/migration/getCreateTableColumnsV1.js +12 -6
- package/dist/migration/getCreateTableColumnsV1.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -2
- package/src/BaseModel.ts +6 -5
- package/src/DbNamingStrategy.ts +17 -35
- package/src/DefaultSubscriber.ts +33 -29
- package/src/dataSource/dataSource.ts +3 -3
- package/src/dataSource/getRepository.ts +4 -4
- package/src/decorators/FileColumn/FileColumn.ts +9 -9
- package/src/decorators/FileColumn/FileTransformer.ts +6 -6
- package/src/decorators/FileColumn/FileType.ts +4 -4
- package/src/decorators/FileColumn/FileWriter.ts +6 -4
- package/src/migration/getCreateTableColumns.ts +33 -27
- package/src/migration/getCreateTableColumnsV1.ts +30 -24
- package/tsconfig.json +2 -11
package/.eslintrc.cjs
CHANGED
package/.prettierrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"@
|
|
1
|
+
"@ainias42/config/prettierrc.js"
|
package/dist/BaseModel.d.ts
CHANGED
package/dist/BaseModel.js
CHANGED
|
@@ -11,9 +11,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseModel = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
|
+
const js_helper_1 = require("@ainias42/js-helper");
|
|
14
15
|
class BaseModel {
|
|
15
16
|
constructor() {
|
|
16
17
|
this.id = -1;
|
|
18
|
+
this.createdAt = js_helper_1.DateHelper.newDate();
|
|
19
|
+
this.updatedAt = js_helper_1.DateHelper.newDate();
|
|
20
|
+
this.deletedAt = null;
|
|
21
|
+
this.version = 0;
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
exports.BaseModel = BaseModel;
|
|
@@ -31,7 +36,7 @@ __decorate([
|
|
|
31
36
|
], BaseModel.prototype, "updatedAt", void 0);
|
|
32
37
|
__decorate([
|
|
33
38
|
(0, typeorm_1.DeleteDateColumn)(),
|
|
34
|
-
__metadata("design:type",
|
|
39
|
+
__metadata("design:type", Object)
|
|
35
40
|
], BaseModel.prototype, "deletedAt", void 0);
|
|
36
41
|
__decorate([
|
|
37
42
|
(0, typeorm_1.VersionColumn)(),
|
package/dist/BaseModel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../src/BaseModel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAsH;
|
|
1
|
+
{"version":3,"file":"BaseModel.js","sourceRoot":"","sources":["../src/BaseModel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAsH;AACtH,mDAAiD;AAEjD,MAAa,SAAS;IAAtB;QAEI,OAAE,GAAW,CAAC,CAAC,CAAC;QAGhB,cAAS,GAAS,sBAAU,CAAC,OAAO,EAAE,CAAC;QAGvC,cAAS,GAAS,sBAAU,CAAC,OAAO,EAAE,CAAC;QAGvC,cAAS,GAAgB,IAAI,CAAC;QAG9B,YAAO,GAAW,CAAC,CAAC;IACxB,CAAC;CAAA;AAfD,8BAeC;AAbG;IADC,IAAA,gCAAsB,GAAE;;qCACT;AAGhB;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;4CAAwB;AAGvC;IADC,IAAA,0BAAgB,GAAE;8BACR,IAAI;4CAAwB;AAGvC;IADC,IAAA,0BAAgB,GAAE;;4CACW;AAG9B;IADC,IAAA,uBAAa,GAAE;;0CACI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DefaultNamingStrategy } from
|
|
2
|
-
import type { NamingStrategyInterface, Table } from
|
|
1
|
+
import { DefaultNamingStrategy } from 'typeorm';
|
|
2
|
+
import type { NamingStrategyInterface, Table } from 'typeorm';
|
|
3
3
|
export declare class DbNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface {
|
|
4
4
|
private createKey;
|
|
5
5
|
indexName(tableOrName: Table | string, columnNames: string[], where?: string): string;
|
package/dist/DbNamingStrategy.js
CHANGED
|
@@ -7,34 +7,34 @@ class DbNamingStrategy extends typeorm_1.DefaultNamingStrategy {
|
|
|
7
7
|
const clonedColumnNames = [...columnNames];
|
|
8
8
|
clonedColumnNames.sort();
|
|
9
9
|
const tableName = this.getTableName(tableOrName);
|
|
10
|
-
const replacedTableName = tableName.replace(
|
|
11
|
-
let key = `${prefix}_${replacedTableName}_${clonedColumnNames.join(
|
|
10
|
+
const replacedTableName = tableName.replace('.', '_');
|
|
11
|
+
let key = `${prefix}_${replacedTableName}_${clonedColumnNames.join('_')}`;
|
|
12
12
|
if (suffix) {
|
|
13
13
|
key += `_${suffix}`;
|
|
14
14
|
}
|
|
15
15
|
return key;
|
|
16
16
|
}
|
|
17
17
|
indexName(tableOrName, columnNames, where) {
|
|
18
|
-
return this.createKey(
|
|
18
|
+
return this.createKey('IDX', tableOrName, columnNames, where);
|
|
19
19
|
}
|
|
20
20
|
foreignKeyName(tableOrName, columnNames) {
|
|
21
|
-
return this.createKey(
|
|
21
|
+
return this.createKey('FK', tableOrName, columnNames);
|
|
22
22
|
}
|
|
23
23
|
uniqueConstraintName(tableOrName, columnNames) {
|
|
24
24
|
// There is a bug in the cli. They use the indexName method to generate unique constraint names
|
|
25
|
-
return this.createKey(
|
|
25
|
+
return this.createKey('IDX', tableOrName, columnNames);
|
|
26
26
|
}
|
|
27
27
|
primaryKeyName(tableOrName, columnNames) {
|
|
28
|
-
return this.createKey(
|
|
28
|
+
return this.createKey('PK', tableOrName, columnNames);
|
|
29
29
|
}
|
|
30
30
|
relationConstraintName(tableOrName, columnNames, where) {
|
|
31
|
-
return this.createKey(
|
|
31
|
+
return this.createKey('REL', tableOrName, columnNames, where);
|
|
32
32
|
}
|
|
33
33
|
checkConstraintName(tableOrName, expression, isEnum) {
|
|
34
|
-
return this.createKey(
|
|
34
|
+
return this.createKey('CHK', tableOrName, [expression], isEnum ? 'ENUM' : undefined);
|
|
35
35
|
}
|
|
36
36
|
exclusionConstraintName(tableOrName, expression) {
|
|
37
|
-
return this.createKey(
|
|
37
|
+
return this.createKey('XCL', tableOrName, [expression]);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.DbNamingStrategy = DbNamingStrategy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbNamingStrategy.js","sourceRoot":"","sources":["../src/DbNamingStrategy.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAGhD,MAAa,gBAAiB,SAAQ,+BAAqB;
|
|
1
|
+
{"version":3,"file":"DbNamingStrategy.js","sourceRoot":"","sources":["../src/DbNamingStrategy.ts"],"names":[],"mappings":";;;AAAA,qCAAgD;AAGhD,MAAa,gBAAiB,SAAQ,+BAAqB;IAC/C,SAAS,CAAC,MAAc,EAAE,WAA2B,EAAE,WAAqB,EAAE,MAAe;QACjG,MAAM,iBAAiB,GAAG,CAAC,GAAG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KAAK,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACzF,CAAC;IAED,uBAAuB,CAAC,WAA2B,EAAE,UAAkB;QACnE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;CACJ;AAzCD,4CAyCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnMetadata } from
|
|
2
|
-
import { EntitySubscriberInterface, InsertEvent, ObjectLiteral, UpdateEvent } from
|
|
1
|
+
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata';
|
|
2
|
+
import { EntitySubscriberInterface, InsertEvent, ObjectLiteral, UpdateEvent } from 'typeorm';
|
|
3
3
|
export declare class DefaultSubscriber implements EntitySubscriberInterface {
|
|
4
4
|
saveFiles(entity: ObjectLiteral, columns: ColumnMetadata[]): Promise<void>;
|
|
5
5
|
/**
|
|
@@ -22,9 +22,9 @@ let DefaultSubscriber = class DefaultSubscriber {
|
|
|
22
22
|
values = [values];
|
|
23
23
|
single = true;
|
|
24
24
|
}
|
|
25
|
-
promises.push(Promise.all(values.map(value => FileWriter_1.FileWriter.writeToFile(value.src, transformer.fileOptions.saveDirectory).then(newUrl => {
|
|
25
|
+
promises.push(Promise.all(values.map((value) => FileWriter_1.FileWriter.writeToFile(value.src, transformer.fileOptions.saveDirectory).then((newUrl) => {
|
|
26
26
|
return Object.assign(Object.assign({}, value), { src: newUrl });
|
|
27
|
-
}))).then(newValues => {
|
|
27
|
+
}))).then((newValues) => {
|
|
28
28
|
if (single) {
|
|
29
29
|
Reflect.set(entity, column.propertyName, newValues[0]);
|
|
30
30
|
}
|
|
@@ -42,10 +42,10 @@ let DefaultSubscriber = class DefaultSubscriber {
|
|
|
42
42
|
*/
|
|
43
43
|
async beforeInsert({ entity, metadata: { columns } }) {
|
|
44
44
|
if (entity) {
|
|
45
|
-
Reflect.set(entity,
|
|
46
|
-
Reflect.set(entity,
|
|
47
|
-
if (Reflect.get(entity,
|
|
48
|
-
Reflect.set(entity,
|
|
45
|
+
Reflect.set(entity, 'updatedAt', new Date());
|
|
46
|
+
Reflect.set(entity, 'createdAt', new Date());
|
|
47
|
+
if (Reflect.get(entity, 'id') <= 0) {
|
|
48
|
+
Reflect.set(entity, 'id', undefined);
|
|
49
49
|
}
|
|
50
50
|
await this.saveFiles(entity, columns);
|
|
51
51
|
}
|
|
@@ -67,7 +67,7 @@ let DefaultSubscriber = class DefaultSubscriber {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
if (event.entity) {
|
|
70
|
-
Reflect.set(event.entity,
|
|
70
|
+
Reflect.set(event.entity, 'updatedAt', new Date());
|
|
71
71
|
}
|
|
72
72
|
const { columns } = event.metadata;
|
|
73
73
|
const { entity } = event;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSubscriber.js","sourceRoot":"","sources":["../src/DefaultSubscriber.ts"],"names":[],"mappings":";;;;;;;;;AAEA,qCAOiB;AAGjB,mEAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;
|
|
1
|
+
{"version":3,"file":"DefaultSubscriber.js","sourceRoot":"","sources":["../src/DefaultSubscriber.ts"],"names":[],"mappings":";;;;;;;;;AAEA,qCAOiB;AAGjB,mEAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,KAAK,CAAC,SAAS,CAAC,MAAqB,EAAE,OAAyB;QAC5D,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,WAA0C,CAAC;YACtE,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE,CAAC;gBACtB,IAAI,MAAM,GAAsC,OAAO,CAAC,GA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K,CAAC;QACzB,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;CAKJ,CAAA;AAxFY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,yBAAe,GAAE;GACL,iBAAiB,CAwF7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataSource } from
|
|
2
|
-
import type { DataSourceOptions } from
|
|
1
|
+
import { DataSource } from 'typeorm';
|
|
2
|
+
import type { DataSourceOptions } from 'typeorm/data-source/DataSourceOptions';
|
|
3
3
|
export declare function initDataSource(options: DataSourceOptions): Promise<void>;
|
|
4
4
|
export declare function getDataSource(): DataSource;
|
|
@@ -10,7 +10,7 @@ async function initDataSource(options) {
|
|
|
10
10
|
}
|
|
11
11
|
function getDataSource() {
|
|
12
12
|
if (!dataSource || !dataSource.isInitialized) {
|
|
13
|
-
throw new Error(
|
|
13
|
+
throw new Error('Data source is not initialized');
|
|
14
14
|
}
|
|
15
15
|
return dataSource;
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityTarget } from
|
|
2
|
-
import type { ObjectLiteral } from
|
|
3
|
-
import type { Repository } from
|
|
1
|
+
import type { EntityTarget } from 'typeorm/common/EntityTarget';
|
|
2
|
+
import type { ObjectLiteral } from 'typeorm/common/ObjectLiteral';
|
|
3
|
+
import type { Repository } from 'typeorm';
|
|
4
4
|
export declare function getRepository<Entity extends ObjectLiteral>(entity: EntityTarget<Entity>): Repository<Entity>;
|
|
@@ -7,9 +7,9 @@ function FileColumn(options) {
|
|
|
7
7
|
(0, typeorm_1.getMetadataArgsStorage)().columns.push({
|
|
8
8
|
target: object.constructor,
|
|
9
9
|
propertyName,
|
|
10
|
-
mode:
|
|
10
|
+
mode: 'regular',
|
|
11
11
|
options: {
|
|
12
|
-
type:
|
|
12
|
+
type: 'json',
|
|
13
13
|
isFile: true,
|
|
14
14
|
nullable: true,
|
|
15
15
|
transformer: {
|
|
@@ -41,7 +41,7 @@ function FileColumn(options) {
|
|
|
41
41
|
single = true;
|
|
42
42
|
}
|
|
43
43
|
for (const value of values) {
|
|
44
|
-
if (!value.src.startsWith(
|
|
44
|
+
if (!value.src.startsWith('data:')) {
|
|
45
45
|
value.src = options.publicPath + value.src;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -50,8 +50,8 @@ function FileColumn(options) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return values;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
};
|
|
@@ -22,7 +22,10 @@ exports.FileWriter = {
|
|
|
22
22
|
const seed = crypto_1.default.randomBytes(20);
|
|
23
23
|
const now = new Date();
|
|
24
24
|
// Month is 0-based. Add 1 to get 1-12
|
|
25
|
-
const name = `${now.getUTCFullYear()}-${now.getUTCMonth() + 1}-${now.getUTCDate()}-${fileType}-${crypto_1.default
|
|
25
|
+
const name = `${now.getUTCFullYear()}-${now.getUTCMonth() + 1}-${now.getUTCDate()}-${fileType}-${crypto_1.default
|
|
26
|
+
.createHash('sha1')
|
|
27
|
+
.update(seed)
|
|
28
|
+
.digest('hex')}.${fileEnding}`;
|
|
26
29
|
const dataBuffer = Buffer.from(data, 'base64');
|
|
27
30
|
const inputStream = new stream_1.Readable();
|
|
28
31
|
const dataStream = new stream_1.PassThrough();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileWriter.js","sourceRoot":"","sources":["../../../src/decorators/FileColumn/FileWriter.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA+C;AAC/C,2BAA8D;AAC9D,oDAA4B;
|
|
1
|
+
{"version":3,"file":"FileWriter.js","sourceRoot":"","sources":["../../../src/decorators/FileColumn/FileWriter.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA+C;AAC/C,2BAA8D;AAC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AC,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,iBAAQ,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,IAAI,oBAAW,EAAE,CAAC;QAErC,IAAI,CAAC,IAAA,eAAU,EAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,IAAA,cAAS,EAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,WAAW,GAAG,IAAA,sBAAiB,EAAC,aAAa,GAAG,IAAI,CAAC,CAAC;QAC5D,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAE7B,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,sDAAsD;QACtD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvB,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/E,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7B,MAAM,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAC"}
|
|
@@ -3,32 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCreateTableColumns = getCreateTableColumns;
|
|
4
4
|
// Do not change the columns here. It is needed for migration, aka creation of the database
|
|
5
5
|
function getCreateTableColumns() {
|
|
6
|
-
return [
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
7
8
|
name: 'id',
|
|
8
9
|
type: 'int',
|
|
9
10
|
isPrimary: true,
|
|
10
11
|
isGenerated: true,
|
|
11
12
|
generationStrategy: 'increment',
|
|
12
13
|
isNullable: false,
|
|
13
|
-
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
14
16
|
name: 'createdAt',
|
|
15
17
|
type: 'datetime(6)',
|
|
16
18
|
isNullable: false,
|
|
17
|
-
default:
|
|
18
|
-
},
|
|
19
|
+
default: 'CURRENT_TIMESTAMP(6)',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
19
22
|
name: 'updatedAt',
|
|
20
23
|
type: 'datetime(6)',
|
|
21
24
|
isNullable: false,
|
|
22
|
-
default:
|
|
23
|
-
onUpdate:
|
|
24
|
-
},
|
|
25
|
+
default: 'CURRENT_TIMESTAMP(6)',
|
|
26
|
+
onUpdate: 'CURRENT_TIMESTAMP(6)',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
25
29
|
name: 'deletedAt',
|
|
26
30
|
type: 'datetime(6)',
|
|
27
31
|
isNullable: true,
|
|
28
|
-
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
29
34
|
name: 'version',
|
|
30
35
|
type: 'int',
|
|
31
36
|
isNullable: false,
|
|
32
|
-
}
|
|
37
|
+
},
|
|
38
|
+
];
|
|
33
39
|
}
|
|
34
40
|
//# sourceMappingURL=getCreateTableColumns.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCreateTableColumns.js","sourceRoot":"","sources":["../../src/migration/getCreateTableColumns.ts"],"names":[],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"getCreateTableColumns.js","sourceRoot":"","sources":["../../src/migration/getCreateTableColumns.ts"],"names":[],"mappings":";;AACA,sDAkCC;AAnCD,2FAA2F;AAC3F,SAAgB,qBAAqB;IACjC,OAAO;QACH;YACI,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,kBAAkB,EAAE,WAAW;YAC/B,UAAU,EAAE,KAAK;SACpB;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,sBAAsB;SAClC;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,sBAAsB;YAC/B,QAAQ,EAAE,sBAAsB;SACnC;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,IAAI;SACnB;QACD;YACI,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,KAAK;YACX,UAAU,EAAE,KAAK;SACpB;KACK,CAAC;AACf,CAAC"}
|
|
@@ -3,29 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCreateTableColumnsV1 = getCreateTableColumnsV1;
|
|
4
4
|
// Do not change the columns here. It is needed for migration, aka creation of the database
|
|
5
5
|
function getCreateTableColumnsV1() {
|
|
6
|
-
return [
|
|
6
|
+
return [
|
|
7
|
+
{
|
|
7
8
|
name: 'id',
|
|
8
9
|
type: 'int',
|
|
9
10
|
isPrimary: true,
|
|
10
11
|
isGenerated: true,
|
|
11
12
|
generationStrategy: 'increment',
|
|
12
13
|
isNullable: false,
|
|
13
|
-
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
14
16
|
name: 'createdAt',
|
|
15
17
|
type: 'datetime',
|
|
16
18
|
isNullable: false,
|
|
17
|
-
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
18
21
|
name: 'updatedAt',
|
|
19
22
|
type: 'datetime',
|
|
20
23
|
isNullable: false,
|
|
21
|
-
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
22
26
|
name: 'deletedAt',
|
|
23
27
|
type: 'datetime(6)',
|
|
24
28
|
isNullable: true,
|
|
25
|
-
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
26
31
|
name: 'version',
|
|
27
32
|
type: 'int',
|
|
28
33
|
isNullable: false,
|
|
29
|
-
}
|
|
34
|
+
},
|
|
35
|
+
];
|
|
30
36
|
}
|
|
31
37
|
//# sourceMappingURL=getCreateTableColumnsV1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCreateTableColumnsV1.js","sourceRoot":"","sources":["../../src/migration/getCreateTableColumnsV1.ts"],"names":[],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"getCreateTableColumnsV1.js","sourceRoot":"","sources":["../../src/migration/getCreateTableColumnsV1.ts"],"names":[],"mappings":";;AACA,0DA+BC;AAhCD,2FAA2F;AAC3F,SAAgB,uBAAuB;IACnC,OAAO;QACH;YACI,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,kBAAkB,EAAE,WAAW;YAC/B,UAAU,EAAE,KAAK;SACpB;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,KAAK;SACpB;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,KAAK;SACpB;QACD;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,IAAI;SACnB;QACD;YACI,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,KAAK;YACX,UAAU,EAAE,KAAK;SACpB;KACK,CAAC;AACf,CAAC"}
|