0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

bin/cake bake migration_snapshot Initialをするときにはtinyintに注意する

Posted at

やりたこと

こちらのコマンドで、既存のDBからMigrationファイルを生成すると、booleanとして扱いたいtinyintのカラムがtinyintegerとしてMigrationファイルを生成してしまう。
tinyintはbooleanに変換したい。

環境(今回の作業に関連ないものも記載)

  • cakephp4.1.2

実装

こちらをベースに、sedを追加した。
データベースをtinyint(1)とかにしてもtinyintegerのままだったので、ファイル生成した後に置換することで対応した。

rm -f ./config/Migrations/*_Initial.php
bin/cake bake migration_snapshot Initial
sed -i -e 's/tinyinteger/boolean/g' ./config/Migrations/*_Initial.php
bin/cake migrations rollback -d 20200101
bin/cake migrations migrate
bin/cake migrations seed --seed LocalSeed
bin/cake bake baked_model all -f
bin/cake bake extended_model all -f

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?