migrations
migrations copied to clipboard
Issue in Many to Many table when generating migrations from an existing database
This is a (multiple allowed):
-
[x] 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 tried to prove the generation and import of a simple datable with a belongstomany relation: books---<books_words>---words first I've tried to generate the table with
bin/cake* bake migration_snapshot Initial* when the book_words is generated the primary_key is blank
Expected Behavior
$this->table('books_words', ['id' => false])
->addColumn('values', 'string', [
'default' => null,
'limit' => 45,
'null' => true,
])
->addColumn('word_id', 'uuid', [
'default' => null,
'limit' => null,
'null' => false,
])
->addColumn('book_id', 'uuid', [
'default' => null,
'limit' => null,
'null' => false,
])
->addIndex(
[
'book_id',
]
)
->addIndex(
[
'word_id',
]
)
->create();
Actual Behavior
$this->table('books_words', ['id' => false, 'primary_key' => ['']])
->addColumn('values', 'string', [
'default' => null,
'limit' => 45,
'null' => true,
])
->addColumn('word_id', 'uuid', [
'default' => null,
'limit' => null,
'null' => false,
])
->addColumn('book_id', 'uuid', [
'default' => null,
'limit' => null,
'null' => false,
])
->addIndex(
[
'book_id',
]
)
->addIndex(
[
'word_id',
]
)
->create();
Can you share the schema for the 3 tables books, words and books_words so we can reproduce easily.
https://gist.github.com/Josexato/c63c996017b1a55029430e28d4bb3e71
https://gist.github.com/Josexato/c63c996017b1a55029430e28d4bb3e71
Any specific reason to have char (36) instead of integer (11) ?
Also, name varchar(1000) DEFAULT NULL, ?
Do you mean text.
You might want to headover to https://discourse.cakephp.org/
Is this still an issue?