LoginSignup
0
1

More than 5 years have passed since last update.

CakePHP3のMigrationコマンドの使い方

Posted at

環境

CakePHP 3.5

マイグレーションコマンド

一括実行

sh bin/cake migrations migrate

Migration IDを指定して実行

sh bin/cake migrations migrate -t 20180912030211

ロールバック(一つ前に戻す)

sh bin/cake migrations rollback

ロールバック(指定したMigration IDまで戻す)

現在の状態を確認する

sh bin/cake migrations status

Status  Migration ID    Migration Name
 up  20180912030211  CreateHoge0
 up  20180912031300  CreateHoge1
 up  20180912031354  CreateHoge2

「CreateHoge1」と「CreateHoge2」を取り消す

sh bin/cake migrations rollback -t 20180912031300

取り消した結果を表示する(donwとなっているので、取り消された)

sh bin/cake migrations status

Status  Migration ID    Migration Name
 up  20180912030211  CreateHoge0
 down  20180912031300  CreateHoge1
 down  20180912031354  CreateHoge2
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1