1.0.2 • Published 7 years ago
simla v1.0.2
SiMLa - Simple Migration Language
I created this language or compiler just to create knex migration easily for my projects.
Install
Open your terminal and type:
npm install -g simlaUsage
simla [-i <input file>] [-o <output file>] [-p] [-s]
-i Input file
-o Output file
-p Print output to terminal
-s Open interactive compilerPS: Interactive compiler won't start if -i parametr is presented.
If you want to compile structure.sml to migration.js, then type:
simla -i structure.sml -o migration.jsStructure
TABLE <table name> {
<type>(<size>) <name> <props>
<type>(<size>) <name> <props> > <reference>
<type>(<size>) <name> <props> > <table>.<field>
}Example
TABLE products {
ID
STRING(100) name NOT NULL
STRING(100) details
DECIMAL(8, 2) price
UINT seller_id > sellers.id
TS
}Types
| Name | Description |
|---|---|
ID | Autoincrement primary key |
TS | Timestamps (created_at, updated_at) |
UINT | Unsigned integer |
INT | Integer |
BOOL | Boolean |
| * | Any exists type with UPPERCASE characters |
Props
| Name | Alias | Description |
|---|---|---|
NOT NULL | NN, NOT_NULL | Property is not nullable |
DEFAULT | DEF | Sets default value for property. Eg.: INT price DEF 0 |
UNSIGNED | US | Makes property un-signed |
Enums?
Here's an example to know how to model enums with SiMLa.
TABLE car {
ID
STRING name
ENUM(['red', 'green', 'blue']) color DEFAULT red
TS
}And, Interactive compiler
It looks like that. To launch compiler open terminal and type: simla -s
