Skip to Content
This documentation is still under construction

title: “Add Column” description: “Add one or more columns to an existing PostgreSQL or MySQL table with the addcolumn key inside altertable.”

Add Column

The addcolumn method allows you to add one or more columns to an existing table.

Usage

To add columns, use the addcolumn key inside an altertable definition. For each column you want to add, specify its properties just as you would in a createtable definition.

{ "_id": "1.1.0", "altertable": { "users": { "addcolumn": { "email": { "type": "VARCHAR", "length": 255, "unique": true, "null": false }, "created_at": { "type": "TIMESTAMP", "default": "CURRENT_TIMESTAMP" } } } } }

In this example, two new columns, email and created_at, are added to the users table.

Column types differ per engine, for example DATETIME instead of TIMESTAMP on MySQL. See Database engines.

Last updated on