i made a model, i added columns with an migration, and after that added another column.
but that last one is now at the end of the table, but want it to be before the timestamps, i forgot to add the after() when creating the column. offcourse i can now delete the column and make it again with after(), but actualy i want to move it (in case you want to move it later on in the proces with an migration). And, offcourse, i can do it with DB::, but i think the idea of the migrations would be to do it with only Scheme::
i tried a migration with:
public function up()
{
//
Schema::table('products', function ($table) {
$table->string('concatted_title')->after('delivery')->change();
});
}
but it didn't work, so i tried a modifyAfter function, found in vendor\laravel\framework\src\Illuminate\Database\Schema\Grammars\MySqlGrammar.php:
public function up()
{
Schema::table('products', function ($table) {
$table->string('concatted_title')->modifyAfter('delivery');
});
}
but as i expected, it isn't used, it all don't work.
The advice on laravel.io forum was to report it as a bug, becouse, well, actually it is a bug. or maybe feature request, but as the code allready excist (the first one, after()->change() ), and doesn't do what you expect it to do (change the position), i think its actually a bug ;)
Bart
Not all modifiers work with change() actually, so I think it's not valid to consider it as a bug :)
I'm closing the issue but please feel free to open a PR if you ever find a way to add this functionality.
is it somewhere in the documentation what modifiers works with change() and what doesn't?
@themsaid ?
Well laravel schema commands are based on doctrine's, and since changing the column order is only supported by MySQL I saw multiple issues regarding this manner before that end up recommending using sql statements as no plans to support this in doctrine.
Too busy to search more, but here's one: https://github.com/doctrine/dbal/issues/1411
@themsaid
Sorry, but I feel, that this has to be exposed in the docs. I don't think, that this issue should be closed.
@Denis4yk feel free at https://github.com/laravel/docs or discuss it further at https://github.com/laravel/internals/issues
after() work for MySQL only
Most helpful comment
after() work for MySQL only