migration
テーブルを作る
./bin/cake bake migration CreateProducts name:string description:text created modified
マイグレーション実行
./bin/cake migrations migrate
これでproductsテーブルができた。
現在のスナップショット
bin/cake bake migration_snapshot Initial
Seed
bin/cake bake seed Hoges
Seedを設定
public function run() { // $data = []; $data = [ [ 'description' => 'foo', 'created' => date('Y-m-d H:i:s'), ],[ 'description' => 'bar', 'created' => date('Y-m-d H:i:s'), ] ]; $table = $this->table('hoges'); $table->insert($data)->save(); }
実行
bin/cake migrations seed
Sqlite3メモ
セレクト
sqlite> select description, modified, created from hoges;