I am trying to put laravel database migrations in sub folders, but not sure how to do this.
All migration files are located at database/migrations in the app's root folder. For more detailed information on database migrations, please refer to our guide on How To Use Database Migrations and Seeders to Abstract Database Setup in Laravel.
To run the specific migration in Laravel, you need to use --path option with the php artisan migrate command. Let's take a simple example, we have '2019_12_04_131405_create_payments_table. php' migration in the database/migrations directory and we would like to run this migration.
IF you want to re-migrate all the database, you can simply do: php artisan migrate:refresh . IF you want to make sure your database to be clean with your latest changes, you can drop your entire database tables and do php artisan migrate again. Also, you can try php artisan migrate --seed if you have any seeder.
When creating new migrations and executing your migrations, you can pass in a path
parameter through the command line interface to specify the directory it will use to create and run the migrations respectively.
php artisan make:migration create_users_table --path=/path/to/your/migration/directory
php artisan migrate --path=/path/to/your/migration/directory
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