1.0.2 • Published 5 years ago

simla v1.0.2

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
5 years ago

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 simla

Usage

simla [-i <input file>] [-o <output file>] [-p] [-s]

-i  Input file
-o  Output file
-p  Print output to terminal
-s  Open interactive compiler

PS: 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.js

Structure

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

NameDescription
IDAutoincrement primary key
TSTimestamps (created_at, updated_at)
UINTUnsigned integer
INTInteger
BOOLBoolean
*Any exists type with UPPERCASE characters

Props

NameAliasDescription
NOT NULLNN, NOT_NULLProperty is not nullable
DEFAULTDEFSets default value for property. Eg.: INT price DEF 0
UNSIGNEDUSMakes 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

Open local compiler

SiMLa Interactive Compiler