simla

1.0.2 • Public • Published

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

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

Open local compiler

SiMLa Interactive Compiler

Package Sidebar

Install

npm i simla

Weekly Downloads

3

Version

1.0.2

License

Apache-2.0

Unpacked Size

103 kB

Total Files

6

Last publish

Collaborators

  • misircoder