karns
karns

Reputation: 5867

specify bake migration field size - Cake3

Cake3 has a migration wrapper for Phinx. Here is a line to create a table:

bin/cake bake migration CreateJobs name:string age:integer

CakePHP has docs here: http://book.cakephp.org/3.0/en/migrations.html; however, they do not specify how to limit field sizes.

Q How can I specify the size of the field? Am I left to editing the migration file manually?

I'm thinking something like:

bin/cake bake migration CreateJobs name:string(100) age:tinyint

but that does not work.

Upvotes: 0

Views: 171

Answers (1)

ndm
ndm

Reputation: 60463

Custom length values are not supported on the CLI (You may want to suggest this as an enhancement over at GitHub), instead a default value based on the type will be used, see

github.com/cakephp/migrations/blob/1.1.4/README.md#generating-migrations-from-the-cli

Lengths for certain columns are also defaulted:

  • string: 255
  • integer: 11
  • biginteger: 20

So you have to modify the generated files afterwards, or create an extended migration shell/task that uses a column parser that is capable of handling length values.

Upvotes: 2

Related Questions