Database engines
AlphaDB uses one version source format for every supported database. The structure, the methods and most column attributes are the same everywhere. Only a few things depend on the database engine, mainly column types and auto-incrementing columns.
Selecting an engine
The root-level engine key tells AlphaDB which SQL dialect a version source is written for. Supported values are postgres and mysql.
{
"engine": "postgres",
"name": "template-name",
"version": [ ... ]
}The command-line interface requires engine, and verification uses it to pick the right rules. The Rust, Python and Node.js APIs select the engine in code (for example by installing alphadb-postgres or alphadb-mysql), but it’s still good practice to set engine so the version source works everywhere.
Shared syntax
These parts of a version source work the same on every engine:
- Structure: the root keys (
engine,name,version), versions with an_id, and default data. - Methods:
createtableandaltertable, including columns, primary keys, foreign keys, indexes and check constraints. - Column attributes:
| Attribute | Description |
|---|---|
type | The column type. Required when creating a column. The available types depend on the engine. |
length | The column length, such as "length": 255 for a VARCHAR. |
null | Set to true to allow NULL values. Columns are NOT NULL unless "null": true is set. |
unique | Set to true to add a unique constraint. |
default | The default value for the column. See Default values. |
Default values
Strings are quoted for you, so "default": "John" becomes DEFAULT 'John'. Numbers, SQL keywords and function calls are passed through as-is. Recognised keywords are CURRENT_TIMESTAMP, NOW(), CURRENT_DATE, CURRENT_TIME, LOCALTIME, LOCALTIMESTAMP and NULL; any value containing parentheses is treated as a function call.
"created_at": {
"type": "TIMESTAMP",
"default": "CURRENT_TIMESTAMP"
}The engine pages list every supported column type and the rules the verifier checks: