Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addPrimaryKey() function not working #346

Closed
1 of 3 tasks
Josexato opened this issue Jan 10, 2018 · 1 comment
Closed
1 of 3 tasks

addPrimaryKey() function not working #346

Josexato opened this issue Jan 10, 2018 · 1 comment
Labels

Comments

@Josexato
Copy link

Josexato commented Jan 10, 2018

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.5.10

  • Migrations plugin version: 1.7.2

  • Bake plugin version (if relevant): 1.6.0

  • Database server (MySQL, SQLite, Postgres): 5.7.20-0ubuntu0.16.04.1

  • PHP Version: PHP 7.0.22-0ubuntu0.16.04.1

  • Platform / OS: ubuntu0.16.04.1

What you did

I wanted to add a primary key composed by two columns so I created this $this->table('books_words')->addPrimaryKey(['books_id','word_id'])->update();

(full code at https://github.com/Josexato/cakephp_sandbox/blob/ac1edbbf26ebcd16508497adcfe3c105b6cf3967/config/Migrations/20180108172304_AddedPrimaryKeys.php#L11)

Expected Behavior

basically I expected to see something like in the debug ALTER TABLE 'books_words' ADD PRIMARY KEY( 'word_id', 'book_id');

Actual Behavior

The update function did not take into account the "primaryKey" attribute, I added a column just to test if it was working properly and found that the column is added but no primary key is added
(log at https://gist.github.com/Josexato/aa9f8d11ea331b78ad72dfa17725c43c)

I've looked for a functions among the adapters that does somthing the "primaryKey" attribute and I've only found this https://github.com/cakephp/phinx/blame/master/src/Phinx/Db/Adapter/MysqlAdapter.php#L264 in the "createTable()" but no action is taken for update and "primaryKey".

@dereuromark
Copy link
Member

Is this still an issue in 0.12?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants