🛠️ This documentation is still under construction
Modify column

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. Any properties you don't specify will remain unchanged, unless you use recreate.

{
  "_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.