prisma-laravel-migrate 3.0.1 → 3.0.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.
@@ -1,6 +1,6 @@
1
1
  import { ColumnDefinitionGenerator } from "./column-definition.js";
2
2
  import { RuleResolver } from "./rule-definition.js";
3
- import { isForMigrator, parseSilentDirective } from "../../utils/utils.js";
3
+ import { decorate, getConfig, isForMigrator, parseSilentDirective } from "../../utils/utils.js";
4
4
  export class PrismaToLaravelMigrationGenerator {
5
5
  dmmf;
6
6
  columnGen;
@@ -62,6 +62,7 @@ export class PrismaToLaravelMigrationGenerator {
62
62
  const isSilent = isForMigrator(parseSilentDirective(model.documentation ?? ""));
63
63
  return {
64
64
  tableName,
65
+ name: decorate(tableName, getConfig('migrator')),
65
66
  isIgnored: isSilent,
66
67
  local: isSilent,
67
68
  definitions,
@@ -95,15 +95,15 @@ export async function generateLaravelSchema(options) {
95
95
  let seq = idx + 1;
96
96
  let timestamp = formatLaravelTimestamp(now, seq, padWidth);
97
97
  // 3) Check for an existing file (old path before sort/repath)
98
- const existingFile = readdirSync(baseOut).find(f => f.endsWith(`_create_${mig.tableName}_table.php`));
98
+ const existingFile = readdirSync(baseOut).find(f => f.endsWith(`_create_${mig.name}_table.php`));
99
99
  const existingPath = existingFile ? path.join(baseOut, existingFile) : undefined;
100
100
  // 4) If creating new, ensure uniqueness (re-runs within same second)
101
- let fileName = existingFile ?? `${timestamp}_create_${mig.tableName}_table.php`;
101
+ let fileName = existingFile ?? `${timestamp}_create_${mig.name}_table.php`;
102
102
  let filePath = path.join(baseOut, fileName);
103
103
  while (!existingFile && existsSync(filePath)) {
104
104
  seq += 1;
105
105
  timestamp = formatLaravelTimestamp(now, seq, padWidth);
106
- fileName = `${timestamp}_create_${mig.tableName}_table.php`;
106
+ fileName = `${timestamp}_create_${mig.name}_table.php`;
107
107
  filePath = path.join(baseOut, fileName);
108
108
  }
109
109
  // 5) Generate and write (merge from old path, write to new path)
@@ -6,10 +6,10 @@ export function sortMigrations(migrations) {
6
6
  // ⬅️ NEW: drop migrations silenced for the migrator
7
7
  migrations = migrations.filter(m => !m.local);
8
8
  // 1) Build a map: tableName → Migration
9
- const migMap = new Map(migrations.map(m => [m.tableName, m]));
9
+ const migMap = new Map(migrations.map(m => [m.name, m]));
10
10
  // 2) Collect “true” FKs only (skip back‐relation object fields)
11
11
  const rawDeps = new Map();
12
- for (const { tableName } of migrations) {
12
+ for (const { name: tableName } of migrations) {
13
13
  rawDeps.set(tableName, new Set());
14
14
  }
15
15
  for (const m of migrations) {
@@ -24,9 +24,9 @@ export function sortMigrations(migrations) {
24
24
  continue;
25
25
  }
26
26
  const parent = def.relationship.on;
27
- if (!migMap.has(parent) || m.tableName === parent)
27
+ if (!migMap.has(parent) || m.name === parent)
28
28
  continue; // skip external/self
29
- rawDeps.get(m.tableName).add(parent);
29
+ rawDeps.get(m.name).add(parent);
30
30
  }
31
31
  }
32
32
  // 3) Build adjacency (parent → dependents) and in-degree (table → count)
@@ -62,8 +62,8 @@ export function sortMigrations(migrations) {
62
62
  // 5) Cycle check
63
63
  if (sorted.length !== migrations.length) {
64
64
  const cycle = migrations
65
- .map(m => m.tableName)
66
- .filter(t => !sorted.some(s => s.tableName === t));
65
+ .map(m => m.name)
66
+ .filter(t => !sorted.some(s => s.name === t));
67
67
  throw new Error(`Cycle detected in migration dependencies: ${cycle.join(' → ')}`);
68
68
  }
69
69
  console.log('\n📦 Sorted Migration Tables:\n' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Generate laravel migrations and/or models using prisma files",
5
5
  "bin": {
6
6
  "prisma-laravel-migrations": "./dist/cli/migrator.index.js",