@mikro-orm/knex 6.3.13-dev.8 → 6.3.13-dev.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.3.13-dev.8",
3
+ "version": "6.3.13-dev.9",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -66,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.3.12"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.3.13-dev.8",
69
+ "@mikro-orm/core": "6.3.13-dev.9",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -390,7 +390,7 @@ class SchemaComparator {
390
390
  const toProp = this.mapColumnToProperty({ ...toColumn, autoincrement: false });
391
391
  const fromColumnType = this.platform.normalizeColumnType(fromColumn.mappedType.getColumnType(fromProp, this.platform).toLowerCase(), fromProp);
392
392
  const fromNativeEnum = fromTable.nativeEnums[fromColumnType] ?? Object.values(fromTable.nativeEnums).find(e => e.name === fromColumnType && e.schema !== '*');
393
- const toColumnType = this.platform.normalizeColumnType(toColumn.mappedType.getColumnType(toProp, this.platform).toLowerCase(), toProp);
393
+ let toColumnType = this.platform.normalizeColumnType(toColumn.mappedType.getColumnType(toProp, this.platform).toLowerCase(), toProp);
394
394
  const log = (msg, params) => {
395
395
  if (tableName) {
396
396
  const copy = core_1.Utils.copy(params);
@@ -402,8 +402,13 @@ class SchemaComparator {
402
402
  (!fromNativeEnum || `${fromNativeEnum.schema}.${fromNativeEnum.name}` !== toColumnType) &&
403
403
  !(fromColumn.ignoreSchemaChanges?.includes('type') || toColumn.ignoreSchemaChanges?.includes('type')) &&
404
404
  !fromColumn.generated && !toColumn.generated) {
405
- log(`'type' changed for column ${tableName}.${fromColumn.name}`, { fromColumnType, toColumnType });
406
- changedProperties.add('type');
405
+ if (!toColumnType.includes('.') && fromTable.schema && fromTable.schema !== this.platform.getDefaultSchemaName()) {
406
+ toColumnType = `${fromTable.schema}.${toColumnType}`;
407
+ }
408
+ if (fromColumnType !== toColumnType) {
409
+ log(`'type' changed for column ${tableName}.${fromColumn.name}`, { fromColumnType, toColumnType });
410
+ changedProperties.add('type');
411
+ }
407
412
  }
408
413
  if (fromColumn.nullable !== toColumn.nullable && !fromColumn.generated && !toColumn.generated) {
409
414
  log(`'nullable' changed for column ${tableName}.${fromColumn.name}`, { fromColumn, toColumn });
@@ -284,7 +284,9 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
284
284
  if (!column.nativeEnumName) {
285
285
  continue;
286
286
  }
287
- const key = schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' + column.nativeEnumName : column.nativeEnumName;
287
+ const key = schemaName && schemaName !== this.platform.getDefaultSchemaName() && !column.nativeEnumName.includes('.')
288
+ ? schemaName + '.' + column.nativeEnumName
289
+ : column.nativeEnumName;
288
290
  if (changedProperties.has('enumItems') && key in diff.fromTable.nativeEnums) {
289
291
  changedNativeEnums.push([column.nativeEnumName, column.enumItems, diff.fromTable.nativeEnums[key].items]);
290
292
  }
@@ -293,6 +295,11 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
293
295
  // postgres allows only adding new items, the values are case insensitive
294
296
  itemsOld = itemsOld.map(v => v.toLowerCase());
295
297
  const newItems = itemsNew.filter(val => !itemsOld.includes(val.toLowerCase()));
298
+ if (enumName.includes('.')) {
299
+ const [enumSchemaName, rawEnumName] = enumName.split('.');
300
+ ret.push(...newItems.map(val => this.knex.schema.raw(this.helper.getAlterNativeEnumSQL(rawEnumName, enumSchemaName, val, itemsNew, itemsOld))));
301
+ return;
302
+ }
296
303
  ret.push(...newItems.map(val => this.knex.schema.raw(this.helper.getAlterNativeEnumSQL(enumName, schemaName, val, itemsNew, itemsOld))));
297
304
  });
298
305
  }