Laravel 10.xのartisanの「migrate:refresh」コマンドを解説します。
Description
全てのマイグレーションのリセット(down())と再実行(up())
Usage
php artisan migrate:refresh [--database [DATABASE]] [--force] [--path [PATH]] [--realpath] [--seed] [--seeder [SEEDER]] [--step [STEP]]
BashOptions
オプション | 省略形 | 必須 | 説明 |
---|---|---|---|
database | - | - | 使用するデータベース接続 |
force | - | - | 本番時にオペレーションを強制的に実行させる |
path | - | - | 実行されるマイグレーションファイルのパス(複数可 |
realpath | - | - | pathで指定したパスが、絶対パスであることを示す |
seed | - | - | シーダーの実行をする |
seeder | - | - | シーダーのクラス名 |
step | - | - | 復帰させるマイグレーション数 & 再実行 |
Example
no options
php artisan migrate:refresh
Bash INFO Rolling back migrations.
2019_12_14_000001_create_personal_access_tokens_table ................................................................................... 7ms DONE
2019_08_19_000000_create_failed_jobs_table .............................................................................................. 8ms DONE
2014_10_12_100000_create_password_reset_tokens_table .................................................................................... 5ms DONE
2014_10_12_000000_create_users_table .................................................................................................... 5ms DONE
INFO Running migrations.
2014_10_12_000000_create_users_table ................................................................................................... 40ms DONE
2014_10_12_100000_create_password_reset_tokens_table ................................................................................... 20ms DONE
2019_08_19_000000_create_failed_jobs_table ............................................................................................. 16ms DONE
2019_12_14_000001_create_personal_access_tokens_table .................................................................................. 19ms DONE
Plaintextseed
make:migrationにて作成されるdatabase/migrations配下にあるマイグレーションを一緒に実行する。
php artisan migrate:refresh --seed
Bash INFO Rolling back migrations.
2019_12_14_000001_create_personal_access_tokens_table ................................................................................... 4ms DONE
2019_08_19_000000_create_failed_jobs_table .............................................................................................. 6ms DONE
2014_10_12_100000_create_password_reset_tokens_table .................................................................................... 5ms DONE
2014_10_12_000000_create_users_table ................................................................................................... 59ms DONE
INFO Running migrations.
2014_10_12_000000_create_users_table ................................................................................................... 16ms DONE
2014_10_12_100000_create_password_reset_tokens_table ................................................................................... 17ms DONE
2019_08_19_000000_create_failed_jobs_table ............................................................................................. 16ms DONE
2019_12_14_000001_create_personal_access_tokens_table .................................................................................. 21ms DONE
INFO Seeding database.
Database\Seeders\UserSeeder .............................................................................................................. RUNNING
Database\Seeders\UserSeeder ......................................................................................................... 2.56 ms DONE
PlaintextSource
10.x
framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.
11.x
framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php at 11.x · laravel/framework
The Laravel Framework. Contribute to laravel/framework development by creating an account on GitHub.
コメント