Skip to Content
This documentation is still under construction
MethodsCreate table

Create table

Creating tables is done with an object called createtable. Column types and some column attributes depend on the root-level engine value.

Format createtable like this. The JSON snippet below shows createtable inside a MySQL version source. Every object key in createtable represents a table. Every object key inside a table represents a column, except reserved table keys such as primary_key, foreign_key, index, and check.

{ "engine": "mysql", "name": "template-name", "version": [ { "_id": "1.0.0", "createtable": { "table1": { "primary_key": "id", "id": { "type": "INT", "auto_increment": true }, "name": { "type": "VARCHAR", "length": 20, "default": "John" } }, "table2": { "primary_key": "id", "id": { "type": "INT" }, "description": { "type": "TEXT", "null": true } } } } ] }

For Postgres, use Postgres column types and identity syntax. Postgres does not use auto_increment; use generated with "ALWAYS" or "BY DEFAULT" for identity columns.

{ "engine": "postgres", "name": "template-name", "version": [ { "_id": "1.0.0", "createtable": { "table1": { "primary_key": "id", "id": { "type": "INTEGER", "generated": "ALWAYS" }, "name": { "type": "VARCHAR", "length": 20, "default": "John" } } } } ] }
Last updated on