is there anyway I could setup(create) database from migration? I want to run migrate and seed, but beforehand it should create database first.
Any suggestions ?
Thanks
You could create custom artisan command and run it before migrate
command.
Inside the command use raw query, you can try something like this:
DB::statement('CREATE DATABASE :db', ['db' => $newDatabase]);
you can do this by new Artisan Command...
php artisan make:database {database-name} {connection-name}
but you have to creat this command first.
check this link
How to create new empty database with Laravel over Model
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With