@mikro-orm/core 7.1.2 → 7.1.3-dev.1

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.
@@ -1379,15 +1379,17 @@ export class MetadataDiscovery {
1379
1379
  }
1380
1380
  // When multiple STI children share the same unique relation (OneToOne/ManyToOne),
1381
1381
  // replace the simple unique with a composite one including the discriminator column
1382
- // so different subtypes can independently reference the same target row.
1383
- if (rootProp?.unique &&
1384
- newProp.unique &&
1385
- [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(newProp.kind)) {
1382
+ // so different subtypes can independently reference the same target row. The second
1383
+ // child already cleared `rootProp.unique`, so for 3+ children we key on the shared
1384
+ // root property existing rather than its (now false) flag, and dedupe the composite.
1385
+ if (rootProp && newProp.unique && [ReferenceKind.ONE_TO_ONE, ReferenceKind.MANY_TO_ONE].includes(newProp.kind)) {
1386
1386
  newProp.unique = false;
1387
1387
  rootProp.unique = false;
1388
- meta.root.uniques.push({
1389
- properties: [prop.name, meta.root.discriminatorColumn],
1390
- });
1388
+ const properties = [prop.name, meta.root.discriminatorColumn];
1389
+ const exists = meta.root.uniques.some(u => Utils.equals(Utils.asArray(u.properties), properties));
1390
+ if (!exists) {
1391
+ meta.root.uniques.push({ properties });
1392
+ }
1391
1393
  }
1392
1394
  newProp.nullable = true;
1393
1395
  newProp.inherited = !rootProp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.1.2",
3
+ "version": "7.1.3-dev.1",
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",
@@ -814,6 +814,20 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
814
814
  * @default []
815
815
  */
816
816
  ignoreSchema?: string[];
817
+ /**
818
+ * Leave database triggers unmanaged. Declared triggers are still created, but existing triggers are never
819
+ * dropped or altered based on the entity metadata — use this to protect hand-written triggers from being
820
+ * removed when they are not mirrored in the entity definitions.
821
+ * @default false
822
+ */
823
+ ignoreTriggers?: boolean;
824
+ /**
825
+ * Leave database stored routines (functions/procedures) unmanaged. New routines are still created, but existing
826
+ * routines are never dropped or altered based on the entity metadata — use this to safely adopt routine support
827
+ * without having pre-existing, hand-written routines removed when they are not mirrored in your metadata.
828
+ * @default false
829
+ */
830
+ ignoreRoutines?: boolean;
817
831
  /**
818
832
  * Table names or patterns to skip during schema generation.
819
833
  * @default []
@@ -90,6 +90,8 @@ const DEFAULTS = {
90
90
  schemaGenerator: {
91
91
  createForeignKeyConstraints: true,
92
92
  ignoreSchema: [],
93
+ ignoreTriggers: false,
94
+ ignoreRoutines: false,
93
95
  skipTables: [],
94
96
  skipViews: [],
95
97
  skipColumns: {},
package/utils/Utils.js CHANGED
@@ -141,7 +141,7 @@ export function parseJsonSafe(value) {
141
141
  /** Collection of general-purpose utility methods used throughout the ORM. */
142
142
  export class Utils {
143
143
  static PK_SEPARATOR = '~~~';
144
- static #ORM_VERSION = '7.1.2';
144
+ static #ORM_VERSION = '7.1.3-dev.1';
145
145
  /**
146
146
  * Checks if the argument is instance of `Object`. Returns false for arrays.
147
147
  */
package/utils/env-vars.js CHANGED
@@ -85,6 +85,8 @@ export function loadEnvironmentVars() {
85
85
  const read3 = read.bind(null, ret.schemaGenerator, 'MIKRO_ORM_SCHEMA_GENERATOR_');
86
86
  read3('disableForeignKeys', bool);
87
87
  read3('createForeignKeyConstraints', bool);
88
+ read3('ignoreTriggers', bool);
89
+ read3('ignoreRoutines', bool);
88
90
  cleanup(ret, 'schemaGenerator');
89
91
  ret.seeder = {};
90
92
  const read4 = read.bind(null, ret.seeder, 'MIKRO_ORM_SEEDER_');