Modify Column
The modifycolumn method allows you to change the properties of an existing column.
Usage
To modify a column, use the modifycolumn key inside an altertable definition. Specify the new properties for the column. For MySQL, any properties you don’t specify will remain unchanged when recreate is false; if recreate is true, the column is rebuilt from the properties you provide.
{
"_id": "1.2.0",
"altertable": {
"users": {
"modifycolumn": {
"email": {
"type": "VARCHAR",
"length": 512,
"unique": false
}
}
}
}
}Recreating a Column
If you need to make a change that requires a column to be dropped and recreated (like changing a column’s fundamental type in a way that requires a full table scan), you can set the recreate flag to true. This will drop all previous properties of the column.
{
"_id": "1.3.0",
"altertable": {
"users": {
"modifycolumn": {
"email": {
"recreate": true,
"type": "TEXT",
"null": true
}
}
}
}
}In this example, the email column will be completely recreated as a TEXT column, and all its previous properties (like length and unique) will be removed.
Postgres behavior
Postgres column modifications are emitted as separate ALTER COLUMN statements. AlphaDB reads the current column type from previous versions, so you can change attributes such as null, default, unique, or generated without repeating the type.
{
"_id": "1.3.0",
"altertable": {
"users": {
"modifycolumn": {
"email": {
"null": true,
"default": "[email protected]"
}
}
}
}
}