title: “Rename Column” description: “Rename columns in an existing table with the renamecolumn key inside altertable.”
Rename Column
The renamecolumn method allows you to change the name of an existing column.
Usage
To rename a column, use the renamecolumn key inside an altertable definition. Provide an object where each key is the old column name and its value is the new column name.
{
"_id": "1.5.0",
"altertable": {
"users": {
"renamecolumn": {
"user_nickname": "username",
"signup_date": "created_at"
}
}
}
}In this example:
- The user_nickname column will be renamed to username.
- The signup_date column will be renamed to created_at.
Last updated on