@famgia/omnify-laravel 2.0.15 → 2.0.16

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.
@@ -1373,12 +1373,23 @@ function formatDropColumn(columnName, prop) {
1373
1373
  lines.push(`$table->dropColumn('${snakeColumn}');`);
1374
1374
  return lines;
1375
1375
  }
1376
- function formatRenameColumn(oldName, newName) {
1376
+ function formatRenameColumn(oldName, newName, prop) {
1377
+ if (prop && isAssociationWithFkColumn(prop)) {
1378
+ const oldFkColumn = getAssociationFkColumnName(oldName);
1379
+ const newFkColumn = getAssociationFkColumnName(newName);
1380
+ return `$table->renameColumn('${oldFkColumn}', '${newFkColumn}');`;
1381
+ }
1377
1382
  const oldSnake = toColumnName(oldName);
1378
1383
  const newSnake = toColumnName(newName);
1379
1384
  return `$table->renameColumn('${oldSnake}', '${newSnake}');`;
1380
1385
  }
1381
1386
  function formatModifyColumn(columnName, _prevProp, currProp) {
1387
+ if (isAssociationWithFkColumn(currProp)) {
1388
+ const fkColumn = getAssociationFkColumnName(columnName);
1389
+ let code2 = `$table->unsignedBigInteger('${fkColumn}')`;
1390
+ if (currProp.nullable) code2 += "->nullable()";
1391
+ return code2 + "->change();";
1392
+ }
1382
1393
  const snakeColumn = toColumnName(columnName);
1383
1394
  const method = TYPE_METHOD_MAP2[currProp.type] ?? "string";
1384
1395
  let code;
@@ -1437,8 +1448,8 @@ function generateAlterMigrationContent(tableName, change, options = {}) {
1437
1448
  upLines.push(` ${formatModifyColumn(col.column, col.previousDef, col.currentDef)}`);
1438
1449
  downLines.push(` ${formatModifyColumn(col.column, col.currentDef, col.previousDef)}`);
1439
1450
  } else if (col.changeType === "renamed" && col.previousColumn) {
1440
- upLines.push(` ${formatRenameColumn(col.previousColumn, col.column)}`);
1441
- downLines.push(` ${formatRenameColumn(col.column, col.previousColumn)}`);
1451
+ upLines.push(` ${formatRenameColumn(col.previousColumn, col.column, col.currentDef)}`);
1452
+ downLines.push(` ${formatRenameColumn(col.column, col.previousColumn, col.currentDef)}`);
1442
1453
  if (col.modifications && col.modifications.length > 0 && col.previousDef && col.currentDef) {
1443
1454
  upLines.push(` ${formatModifyColumn(col.column, col.previousDef, col.currentDef)}`);
1444
1455
  downLines.push(` ${formatModifyColumn(col.column, col.currentDef, col.previousDef)}`);
@@ -4753,14 +4764,6 @@ function getExistingMigrationTables(migrationsDir) {
4753
4764
  }
4754
4765
  return existingTables;
4755
4766
  }
4756
- function getMigrationsDirForSchema(schema, cwd, defaultMigrationsPath) {
4757
- if (schema?.packageOutput?.laravel) {
4758
- const pkg = schema.packageOutput.laravel;
4759
- const migrationsPath = pkg.migrationsPath ?? "database/migrations";
4760
- return join(cwd, pkg.base, migrationsPath);
4761
- }
4762
- return join(cwd, defaultMigrationsPath);
4763
- }
4764
4767
  function buildExistingTablesMap(schemas, cwd, defaultMigrationsPath) {
4765
4768
  const tablesMap = /* @__PURE__ */ new Map();
4766
4769
  const checkedDirs = /* @__PURE__ */ new Set();
@@ -4780,11 +4783,13 @@ function buildExistingTablesMap(schemas, cwd, defaultMigrationsPath) {
4780
4783
  }
4781
4784
  return tablesMap;
4782
4785
  }
4783
- function tableHasMigration(tableName, schemaName, schemas, existingTablesMap, cwd, defaultMigrationsPath) {
4784
- const schema = schemaName ? schemas[schemaName] : void 0;
4785
- const migrationsDir = getMigrationsDirForSchema(schema, cwd, defaultMigrationsPath);
4786
- const existingTables = existingTablesMap.get(migrationsDir);
4787
- return existingTables?.has(tableName) ?? false;
4786
+ function tableHasMigration(tableName, _schemaName, _schemas, existingTablesMap, _cwd, _defaultMigrationsPath) {
4787
+ for (const existingTables of existingTablesMap.values()) {
4788
+ if (existingTables.has(tableName)) {
4789
+ return true;
4790
+ }
4791
+ }
4792
+ return false;
4788
4793
  }
4789
4794
  var LARAVEL_CONFIG_SCHEMA = {
4790
4795
  fields: [
@@ -4992,7 +4997,8 @@ function laravelPlugin(options) {
4992
4997
  type: "migration",
4993
4998
  metadata: {
4994
4999
  tableName,
4995
- migrationType: "create"
5000
+ migrationType: "create",
5001
+ schemaName: migration.schemaName
4996
5002
  }
4997
5003
  });
4998
5004
  }
@@ -5012,7 +5018,8 @@ function laravelPlugin(options) {
5012
5018
  type: "migration",
5013
5019
  metadata: {
5014
5020
  tableName: migration.tables[0],
5015
- migrationType: migration.type
5021
+ migrationType: migration.type,
5022
+ schemaName: migration.schemaName
5016
5023
  }
5017
5024
  });
5018
5025
  }
@@ -5031,7 +5038,8 @@ function laravelPlugin(options) {
5031
5038
  type: "migration",
5032
5039
  metadata: {
5033
5040
  tableName,
5034
- migrationType: migration.type
5041
+ migrationType: migration.type,
5042
+ schemaName: migration.schemaName
5035
5043
  }
5036
5044
  });
5037
5045
  }
@@ -5246,4 +5254,4 @@ export {
5246
5254
  getFactoryPath,
5247
5255
  laravelPlugin
5248
5256
  };
5249
- //# sourceMappingURL=chunk-3RGYQPB2.js.map
5257
+ //# sourceMappingURL=chunk-F2VU73BX.js.map