Skip to content

Commit

Permalink
Improved guessing of the table name when generating a migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Sakovich committed Jul 14, 2018
1 parent 2a9cad9 commit be79fb8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ public function handle()
}
}

// Next, we will attempt to guess the table name if this the migration has
// "to", "from", "in" in the name. This will allow us to provide a convenient
// way of creating migrations that modify tables in the application.
if (! $table) {
if (preg_match('/_(to|from|in)_(\w+)_table$/', $name, $matches)) {
$table = $matches[2];

$create = false;
}
}

// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
Expand Down

0 comments on commit be79fb8

Please sign in to comment.