Deploy, load or build script from model of SQL database. Can be used as command-line tool. Uses [DbGate](https://dbgate.org) tooling and plugins for connecting many different databases.
If you want to use this tool from JavaScript interface, please use [dbgate-api](https://www.npmjs.com/package/dbgate-api) package.
* views - stored as SQL file with extension **.view.sql**
* stored procedures - stored as SQL file with extension **.proc.sql**
* functions - stored as SQL file with extension **.func.sql**
## Installation - as global tool
npm install --global dbmodel
## Installation - as regular package
npm install --save dbmodel
## Available commands
* **load** - loads structure of database, saves it to local directory (called *project*). Also can download data of enlisted tables (use --load-data-condition options)
* **deploy** - deploys structure from local directory (*project*) to database. *Deploy does not perform any actions leading to data loss, these changes must be made manually.*
* creates not existing tables
* creates not existing columns of existing tables
* checks column NULL/NOT NULL flag, alters colums
* checks tables, which are in database, but not in project, list of these tables are reported
* checks columns, which are in database, but not in project, list of these columns are reported
* checks indexes and its definitions, indexes are created or recreated, if neccessary (*but not deleted*)
* checks and creates foreign keys
* checks, creates new or changes existing views, stored procedures and functions
* updates and creates static data (included in table yaml files)
* **build** - builds script from project folder. This operation is complete offline, no database connection is needed. Built script makes subset of deploy command. It can be executed on empty database, but also it can convert existing database to current structure (but only using operations below).
* creates not existing tables
* creates not existing columns of existing tables
* creates not existing indexes (checked only by name)
* creates not existing foreign keys
* creates new or changes existing views, stored procedures and functions
* updates and creates static data (included in table yaml files)