Is there a way how I can change the migrations order without remaking them all? Because now I have a problem with my foreign keys -_- (working with laravel)
You have to create a custom command that executes
php artisan migrate:refresh --path=/database/migrations/name_migration.php
repeately with the migrations's name in the order you want.
Like this:
php artisan make:command NameClass
app/Console/Commands/
and find the class file NameClass.php
$signature
(the name of the command) and $description
(Information about what your command does). Ex: protected $signature='namecommand'; protected $descripton = 'This method migrate tables in order'
handle()
, here you have to declare the code you want to be executed when you write the command.app/Console/Kernel.php and
add your class to the list of Command Classes.
protected $commands = [
Commands\NameClass::class,
];
php artisan namecommand
Example:
php artisan make:command MigrateInOrder
app/Console/Commands/MigrateInOrder.php
call('migrate:refresh', [
'--path' => $path ,
]);
}
}
}
protected $commands = [
Commands\MigrateInOrder::class,
];
php artisan migrate_in_order