@mikro-orm/sql 7.1.3-dev.0 → 7.1.3-dev.2
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.
|
@@ -536,8 +536,10 @@ export class SqliteSchemaHelper extends SchemaHelper {
|
|
|
536
536
|
this.append(ret, this.getRenameIndexSQL(diff.name, index, oldIndexName));
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
|
-
|
|
540
|
-
|
|
539
|
+
if (!safe) {
|
|
540
|
+
for (const trigger of Object.values(diff.removedTriggers)) {
|
|
541
|
+
this.append(ret, this.dropTrigger(diff.toTable, trigger));
|
|
542
|
+
}
|
|
541
543
|
}
|
|
542
544
|
for (const trigger of Object.values(diff.changedTriggers)) {
|
|
543
545
|
this.append(ret, this.dropTrigger(diff.toTable, trigger));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.3-dev.
|
|
3
|
+
"version": "7.1.3-dev.2",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.1.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.3-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.3-dev.2"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
|
@@ -170,6 +170,8 @@ export class SchemaComparator {
|
|
|
170
170
|
return diff;
|
|
171
171
|
}
|
|
172
172
|
compareRoutines(fromSchema, toSchema, diff) {
|
|
173
|
+
// `ignoreRoutines` makes routines create-only: new ones are still added, but existing routines are never diffed for drop/alter.
|
|
174
|
+
const ignoreRoutines = this.#platform.getConfig().get('schemaGenerator').ignoreRoutines;
|
|
173
175
|
// Case-fold so user-written `'sql_hash'` matches Oracle's introspected `'SQL_HASH'`.
|
|
174
176
|
const routineKey = (r) => ((r.schema ? `${r.schema}.` : '') + r.name).toLowerCase();
|
|
175
177
|
const fromByKey = new Map(fromSchema.getRoutines().map(r => [routineKey(r), r]));
|
|
@@ -181,15 +183,17 @@ export class SchemaComparator {
|
|
|
181
183
|
this.log(`routine ${key} added`);
|
|
182
184
|
continue;
|
|
183
185
|
}
|
|
184
|
-
if (this.diffRoutine(fromRoutine, toRoutine)) {
|
|
186
|
+
if (!ignoreRoutines && this.diffRoutine(fromRoutine, toRoutine)) {
|
|
185
187
|
diff.changedRoutines[key] = { from: fromRoutine, to: toRoutine };
|
|
186
188
|
this.log(`routine ${key} changed`, { fromRoutine, toRoutine });
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
if (!ignoreRoutines) {
|
|
192
|
+
for (const [key, fromRoutine] of fromByKey) {
|
|
193
|
+
if (!toByKey.has(key)) {
|
|
194
|
+
diff.removedRoutines[key] = fromRoutine;
|
|
195
|
+
this.log(`routine ${key} removed`);
|
|
196
|
+
}
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
}
|
|
@@ -493,21 +497,24 @@ export class SchemaComparator {
|
|
|
493
497
|
this.log(`trigger ${trigger.name} added to table ${tableDifferences.name}`, { trigger });
|
|
494
498
|
changes++;
|
|
495
499
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
500
|
+
// `ignoreTriggers` makes triggers create-only: declared ones are still added above, but existing triggers are never diffed for drop/alter.
|
|
501
|
+
if (!this.#platform.getConfig().get('schemaGenerator').ignoreTriggers) {
|
|
502
|
+
for (const trigger of fromTableTriggers) {
|
|
503
|
+
if (!toTable.hasTrigger(trigger.name)) {
|
|
504
|
+
tableDifferences.removedTriggers[trigger.name] = trigger;
|
|
505
|
+
this.log(`trigger ${trigger.name} removed from table ${tableDifferences.name}`);
|
|
506
|
+
changes++;
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
const toTableTrigger = toTable.getTrigger(trigger.name);
|
|
510
|
+
if (this.diffTrigger(trigger, toTableTrigger)) {
|
|
511
|
+
this.log(`trigger ${trigger.name} changed in table ${tableDifferences.name}`, {
|
|
512
|
+
fromTableTrigger: trigger,
|
|
513
|
+
toTableTrigger,
|
|
514
|
+
});
|
|
515
|
+
tableDifferences.changedTriggers[trigger.name] = toTableTrigger;
|
|
516
|
+
changes++;
|
|
517
|
+
}
|
|
511
518
|
}
|
|
512
519
|
}
|
|
513
520
|
const fromForeignKeys = { ...fromTable.getForeignKeys() };
|
package/schema/SchemaHelper.js
CHANGED
|
@@ -386,8 +386,10 @@ export class SchemaHelper {
|
|
|
386
386
|
for (const check of Object.values(diff.changedChecks)) {
|
|
387
387
|
ret.push(this.dropConstraint(diff.name, check.name));
|
|
388
388
|
}
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
if (!safe) {
|
|
390
|
+
for (const trigger of Object.values(diff.removedTriggers)) {
|
|
391
|
+
ret.push(this.dropTrigger(diff.toTable, trigger));
|
|
392
|
+
}
|
|
391
393
|
}
|
|
392
394
|
for (const trigger of Object.values(diff.changedTriggers)) {
|
|
393
395
|
ret.push(this.dropTrigger(diff.toTable, trigger));
|