Changing the primary key
Drop primary key
If you wish to remove a primary key from a table, set it to null.
{
"altertable": {
"table-name": {
"primary_key": null
}
}
}On MySQL, removing the primary key also removes the AUTO_INCREMENT attribute. An AUTO_INCREMENT column is required to have a key, so only removing the primary key would result in an error.
Change primary key
To change the primary key to another column, just supply the column name.
{
"altertable": {
"table-name": {
"primary_key": "column-name"
}
}
}Last updated on