blueprint
blueprint copied to clipboard
Migration path cannot be changed through config
Synopsis:
The migration path is a hard-coded string in MigrationGenerator. Changing this value is necessary for some installations such as multi-tenancy, where migrations for tenants are placed in a subdirectory like "database/migrations/tenants".
Currently, the best/most reasonable way to achieve this is via an extended class:
<?php
namespace App\Blueprints\Generators;
use Carbon\Carbon;
use Illuminate\Support\Str;
class MigrationGenerator extends \Blueprint\Generators\MigrationGenerator {
protected function getTablePath($tableName, Carbon $timestamp, $overwrite = false)
{
$path = parent::getTablePath($tableName, $timestamp, $overwrite);
return Str::replaceFirst('database/migrations/', 'database/migrations/tenants/', $path);
}
}
With a config change to the class used for the generator:
'generators': [
// ...
'migration' => \App\Blueprints\Generators\MigrationGenerator::class,
// ...
]
Proposed Syntax:
Create a "blueprint.migration_path" config setting, with a default value of "database/migrations/"
, and use that setting in the MigrationGenerator class inside the getTablePath
method.
Expected Behavior:
Hoping to be able to adjust the migrations path without having to copy the entire MigrationGenerator class.
@mindfullsilence, this sounds fine. Feel free to open a PR to get things started or I'll see if I can live stream something next week.
This is not something that seems to have gotten any more attention. Furthermore, it creates a slippery slope. If this is configurable, then all paths become configurable. The whole point of Blueprint is its ability to leverage Laravel conventions.
As such, I am closing. However, I am open to a PR if you (or someone reading this in the future) wants to submit a PR adding a configuration option.