DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: Laravel 9: Stub Migrations!

Collapse
thiagorb profile image
Thiago RomΓ£o Barcala • Edited on

@lordisp Firstly, your "before" wouldn't work, because migration classes couldn't be autoloaded. You would need to require/include the file manually, and it could be done only once, otherwise PHP would panic while trying to define the class for the second time. You would also pollute your global namespace.

Secondly, did you ever need to do that? I doubt...

You can do what you described with the following snippet:

$migration = require('app/database/migrations/2019_01_01_000000_add_content_to_posts_table.php');
$migration->up();
Enter fullscreen mode Exit fullscreen mode