Skip to Content
This documentation is still under construction

MySQL syntax

Set "engine": "mysql" to write a version source for MySQL or MariaDB. Everything in shared syntax applies; this page covers what is specific to MySQL.

{ "engine": "mysql", "name": "example-db", "version": [ { "_id": "1.0.0", "createtable": { "users": { "primary_key": "id", "id": { "type": "INT", "auto_increment": true }, "email": { "type": "VARCHAR", "length": 255, "unique": true }, "settings": { "type": "JSON", "null": true }, "created_at": { "type": "DATETIME", "default": "CURRENT_TIMESTAMP" } } } } ] }

Column types

CategoryTypes
IntegerTINYINT, INT, BIGINT
DecimalFLOAT, DECIMAL
TextVARCHAR, TEXT, LONGTEXT
Date and timeDATETIME
OtherJSON

Types are written in uppercase.

Length

length sets the size of a column, such as "length": 255 for a VARCHAR. DECIMAL and FLOAT accept a decimal length; other types need a whole number.

Auto increment

To create an auto-incrementing column, add "auto_increment": true.

"id": { "type": "INT", "auto_increment": true }

The verifier flags these combinations as critical errors:

  • auto_increment together with "null": true.
  • auto_increment on VARCHAR, TEXT, LONGTEXT, DATETIME, DECIMAL or JSON columns.
  • unique on a JSON column.

MySQL-only behaviour

  • Recreating a column: modifycolumn keeps the properties you don’t specify, unless you set recreate to rebuild the column.
  • Dropping a primary key also removes AUTO_INCREMENT from the column.
  • Partial indexes (an index condition) are not supported.
Last updated on