You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Knex version: 2.3.0
Database + version: MySQL 5.7
OS: Windows
Bug
bigincrements does not work with a composite primary key. This is because the ALTER table command run after the CREATE to add the auto_increment only runs when you define an "increments". Logic is missing for bigincrements.
Example
// this works (using increments)
knex.schema.createTable("test_table", table => {
table.primary(['userId', 'name']);
table.increments('userId');
table.string('name');
}
// OUTPUT
[
{
sql: 'create table `test_table` (`userId` int unsigned not null, `name` varchar(255), primary key (`userId`, `name`))',
bindings: []
},
{
sql: 'alter table `test_table` modify column `userId` int unsigned not null auto_increment',
bindings: []
}
]
// this does not work (using bigincrements)
knex.schema.createTable("test_table", table => {
table.primary(['userId', 'name']);
table.bigincrements('userId');
table.string('name');
}
// OUTPUT - missing the alter table command
[
{
sql: 'create table `test_table` (`userId` bigint unsigned not null, `name` varchar(255), primary key (`userId`, `name`))',
bindings: []
}
]
The text was updated successfully, but these errors were encountered:
davidf84
pushed a commit
to davidf84/knex
that referenced
this issue
Oct 2, 2022
Environment
Knex version: 2.3.0
Database + version: MySQL 5.7
OS: Windows
Bug
bigincrements does not work with a composite primary key. This is because the ALTER table command run after the CREATE to add the auto_increment only runs when you define an "increments". Logic is missing for bigincrements.
Example
The text was updated successfully, but these errors were encountered: