@devstroupe/devkit-cli 1.1.10 → 1.1.11
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.
|
@@ -80,23 +80,39 @@ function nestMigrationTemplate(entity, entities, timestamp, properties = entity.
|
|
|
80
80
|
const relationColumns = relationships
|
|
81
81
|
.filter((relationship) => (0, relationships_1.isSingularRelationship)(relationship.kind))
|
|
82
82
|
.map((relationship) => ` { name: '${relationship.foreignKey}', type: 'int', isNullable: ${!relationship.property.required}, isUnique: ${relationship.kind === 'one-to-one'} }`);
|
|
83
|
-
// Gera
|
|
83
|
+
// Gera código TypeORM seguro para cada FK no método UP
|
|
84
84
|
const foreignKeysSql = relationships
|
|
85
85
|
.filter((relationship) => (0, relationships_1.isSingularRelationship)(relationship.kind))
|
|
86
86
|
.map((relationship) => {
|
|
87
87
|
const fkName = `FK_${tableName}_${relationship.foreignKey}`;
|
|
88
88
|
const refTable = targetTable(relationship.target, entities);
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
return ` const table_${relationship.foreignKey} = await queryRunner.getTable('${tableName}');
|
|
90
|
+
if (table_${relationship.foreignKey}) {
|
|
91
|
+
const foreignKey = table_${relationship.foreignKey}.foreignKeys.find(fk => fk.name === '${fkName}');
|
|
92
|
+
if (foreignKey) {
|
|
93
|
+
await queryRunner.dropForeignKey('${tableName}', foreignKey);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
await queryRunner.createForeignKey('${tableName}', new TableForeignKey({
|
|
97
|
+
name: '${fkName}',
|
|
98
|
+
columnNames: ['${relationship.foreignKey}'],
|
|
99
|
+
referencedTableName: '${refTable}',
|
|
100
|
+
referencedColumnNames: ['${relationship.valueField}'],
|
|
101
|
+
onDelete: '${relationship.onDelete}'
|
|
102
|
+
}));`;
|
|
93
103
|
})
|
|
94
104
|
.join('\n');
|
|
95
105
|
const dropForeignKeysSql = relationships
|
|
96
106
|
.filter((relationship) => (0, relationships_1.isSingularRelationship)(relationship.kind))
|
|
97
107
|
.map((relationship) => {
|
|
98
108
|
const fkName = `FK_${tableName}_${relationship.foreignKey}`;
|
|
99
|
-
return ` await queryRunner.
|
|
109
|
+
return ` const table_${relationship.foreignKey} = await queryRunner.getTable('${tableName}');
|
|
110
|
+
if (table_${relationship.foreignKey}) {
|
|
111
|
+
const foreignKey = table_${relationship.foreignKey}.foreignKeys.find(fk => fk.name === '${fkName}');
|
|
112
|
+
if (foreignKey) {
|
|
113
|
+
await queryRunner.dropForeignKey('${tableName}', foreignKey);
|
|
114
|
+
}
|
|
115
|
+
}`;
|
|
100
116
|
})
|
|
101
117
|
.join('\n');
|
|
102
118
|
const junctions = relationships
|
|
@@ -163,7 +179,7 @@ function nestMigrationTemplate(entity, entities, timestamp, properties = entity.
|
|
|
163
179
|
return ` await queryRunner.query('ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${checkName}\`');`;
|
|
164
180
|
}).join('\n')
|
|
165
181
|
: '';
|
|
166
|
-
return `import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
|
|
182
|
+
return `import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableIndex } from 'typeorm';
|
|
167
183
|
|
|
168
184
|
export class ${className} implements MigrationInterface {
|
|
169
185
|
name = '${className}';
|
|
@@ -149,9 +149,9 @@ function assertValidTypeScript(source) {
|
|
|
149
149
|
strict_1.default.match(companyMigration, /name: 'companies'/);
|
|
150
150
|
strict_1.default.doesNotMatch(companyMigration, /FK_companies_cabins/);
|
|
151
151
|
strict_1.default.match(cabinMigration, /name: 'company_id', type: 'int'/);
|
|
152
|
-
strict_1.default.match(cabinMigration, /
|
|
152
|
+
strict_1.default.match(cabinMigration, /createForeignKey/);
|
|
153
153
|
strict_1.default.match(cabinMigration, /FK_cabins_company_id/);
|
|
154
|
-
strict_1.default.match(cabinMigration, /
|
|
154
|
+
strict_1.default.match(cabinMigration, /onDelete: 'CASCADE'/);
|
|
155
155
|
strict_1.default.match(dataSource, /migrations: \[path\.join/);
|
|
156
156
|
strict_1.default.match(dataSource, /synchronize: false/);
|
|
157
157
|
assertValidTypeScript(companyMigration);
|
|
@@ -8,7 +8,7 @@ import { CommonModule } from '@angular/common';
|
|
|
8
8
|
import { HlmButton } from '@spartan-ng/helm/button';
|
|
9
9
|
import { HlmInput } from '@spartan-ng/helm/input';
|
|
10
10
|
import { NgIconComponent } from '@ng-icons/core';
|
|
11
|
-
import type { ThemeMode } from '
|
|
11
|
+
import type { ThemeMode } from '../../../../core/services/theme.service';
|
|
12
12
|
|
|
13
13
|
export interface IUserProfile {
|
|
14
14
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devstroupe/devkit-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "DevsTroupe Development Kit CLI — scaffold NestJS+Angular projects, inject Spartan UI, generate CRUDs and audit architectural governance",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"commander": "^12.0.0",
|
|
38
38
|
"fs-extra": "^11.2.0",
|
|
39
|
-
"@devstroupe/devkit-core": "1.1.
|
|
39
|
+
"@devstroupe/devkit-core": "1.1.11"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/fs-extra": "^11.0.4",
|