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

Tuesday, December 28, 2021

[FIXED] add column with primarykey migrations on update cakephp

 December 28, 2021     cakephp, cakephp-3.0, migration, phinx     No comments   

Issue

I am writing migrations script in cakephp 3 using Phinx. I need to add a column with primary key while updating the table(using update() command) using migrations. But when I run the script, it created the column but does not include the primary key.

  $table->addColumn('book_id', 'integer', [
     'default' => null,
     'limit' => 11,
     'null' => true
  ])->addPrimaryKey('book_id');
  $table->update();

Thanks


Solution

Per the Docs:

Dealing with primary key can only be done on table creation operations. This is due to limitations for some database servers the plugin supports.



Answered By - ahoffner
  • 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