PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 14, 2022

[FIXED] How can i add default value when i want to create new table via console

 April 14, 2022     cakephp, cakephp-3.4, default-value, migration, phinx     No comments   

Issue

I have shell command like this. Tell me please, how can i add default value to this query ?

bin/cake bake migration CreateProducts name:string description:text created modified

Solution

You can't, it's not supported, the column definition syntax is:

fieldName:fieldType?[length]:indexType:indexName

If you want to specify a default, then you need to add that to the migration file manually using the default option of the addColumn() method, like:

$table->addColumn('name', 'string', [
    'default' => 'default value',
    // ...
]);

See also

  • Cookbook > Migrations > Columns Definition
  • Cookbook > Migrations > Creating a table


Answered By - ndm
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing