-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
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
// 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: []
}
]
Metadata
Metadata
Assignees
Labels
No labels