@mikro-orm/sql 7.2.5-dev.6 → 7.2.5-dev.7
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/package.json +2 -2
- package/schema/SchemaComparator.js +12 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.5-dev.
|
|
3
|
+
"version": "7.2.5-dev.7",
|
|
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.2.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.5-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.5-dev.7"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
|
@@ -166,11 +166,12 @@ export class SchemaComparator {
|
|
|
166
166
|
diff.changedTables[viewName] = tableDiff;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
this.compareRoutines(fromSchema, toSchema, diff);
|
|
169
|
+
this.compareRoutines(fromSchema, toSchema, diff, !!inverseDiff);
|
|
170
170
|
return diff;
|
|
171
171
|
}
|
|
172
|
-
compareRoutines(fromSchema, toSchema, diff) {
|
|
172
|
+
compareRoutines(fromSchema, toSchema, diff, inverse) {
|
|
173
173
|
// `ignoreRoutines` makes routines create-only: new ones are still added, but existing routines are never diffed for drop/alter.
|
|
174
|
+
// The down diff (`inverse`) mirrors that: it drops what `up` created and never recreates routines unknown to the metadata.
|
|
174
175
|
const ignoreRoutines = this.#platform.getConfig().get('schemaGenerator').ignoreRoutines;
|
|
175
176
|
// Case-fold so user-written `'sql_hash'` matches Oracle's introspected `'SQL_HASH'`.
|
|
176
177
|
const routineKey = (r) => ((r.schema ? `${r.schema}.` : '') + r.name).toLowerCase();
|
|
@@ -179,6 +180,9 @@ export class SchemaComparator {
|
|
|
179
180
|
for (const [key, toRoutine] of toByKey) {
|
|
180
181
|
const fromRoutine = fromByKey.get(key);
|
|
181
182
|
if (!fromRoutine) {
|
|
183
|
+
if (ignoreRoutines && inverse) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
182
186
|
diff.newRoutines[key] = toRoutine;
|
|
183
187
|
this.log(`routine ${key} added`);
|
|
184
188
|
continue;
|
|
@@ -188,7 +192,7 @@ export class SchemaComparator {
|
|
|
188
192
|
this.log(`routine ${key} changed`, { fromRoutine, toRoutine });
|
|
189
193
|
}
|
|
190
194
|
}
|
|
191
|
-
if (!ignoreRoutines) {
|
|
195
|
+
if (!ignoreRoutines || inverse) {
|
|
192
196
|
for (const [key, fromRoutine] of fromByKey) {
|
|
193
197
|
if (!toByKey.has(key)) {
|
|
194
198
|
diff.removedRoutines[key] = fromRoutine;
|
|
@@ -493,10 +497,12 @@ export class SchemaComparator {
|
|
|
493
497
|
tableDifferences.changedChecks[check.name] = toTableCheck;
|
|
494
498
|
changes++;
|
|
495
499
|
}
|
|
500
|
+
const ignoreTriggers = this.#platform.getConfig().get('schemaGenerator').ignoreTriggers;
|
|
496
501
|
const fromTableTriggers = fromTable.getTriggers();
|
|
497
502
|
const toTableTriggers = toTable.getTriggers();
|
|
498
503
|
for (const trigger of toTableTriggers) {
|
|
499
|
-
|
|
504
|
+
// see `compareRoutines` for how `ignoreTriggers` applies to the down diff
|
|
505
|
+
if (fromTable.hasTrigger(trigger.name) || (ignoreTriggers && inverse)) {
|
|
500
506
|
continue;
|
|
501
507
|
}
|
|
502
508
|
tableDifferences.addedTriggers[trigger.name] = trigger;
|
|
@@ -504,7 +510,7 @@ export class SchemaComparator {
|
|
|
504
510
|
changes++;
|
|
505
511
|
}
|
|
506
512
|
// `ignoreTriggers` makes triggers create-only: declared ones are still added above, but existing triggers are never diffed for drop/alter.
|
|
507
|
-
if (!
|
|
513
|
+
if (!ignoreTriggers || inverse) {
|
|
508
514
|
for (const trigger of fromTableTriggers) {
|
|
509
515
|
if (!toTable.hasTrigger(trigger.name)) {
|
|
510
516
|
tableDifferences.removedTriggers[trigger.name] = trigger;
|
|
@@ -513,7 +519,7 @@ export class SchemaComparator {
|
|
|
513
519
|
continue;
|
|
514
520
|
}
|
|
515
521
|
const toTableTrigger = toTable.getTrigger(trigger.name);
|
|
516
|
-
if (this.diffTrigger(trigger, toTableTrigger)) {
|
|
522
|
+
if (!ignoreTriggers && this.diffTrigger(trigger, toTableTrigger)) {
|
|
517
523
|
this.log(`trigger ${trigger.name} changed in table ${tableDifferences.name}`, {
|
|
518
524
|
fromTableTrigger: trigger,
|
|
519
525
|
toTableTrigger,
|