New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@leapfrogtechnology/sync-db

Package Overview
Dependencies
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leapfrogtechnology/sync-db

Command line utility to synchronize and version control relational database objects across databases

  • 1.0.0-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
264
increased by61.96%
Maintainers
3
Weekly downloads
 
Created
Source

sync-db

Command line utility to synchronize and version control relational database objects across databases.

oclif Version Downloads/week Language grade: JavaScript License

Setup

Installation

$ yarn add @leapfrogtechnology/sync-db

Global Installation

$ yarn global add @leapfrogtechnology/sync-db

Install node database driver(s) of the database(s) that are to be synced, for example this is how you would install the mssql driver:

$ yarn add mssql

Note: If sync-db is installed globally, install database driver(s) globally too.

Configure Database Connections

Create connections-sync-db.json in your project folder and configure your database connection(s) to be synced.

{
  "connections": [
    {
      "id": "db1",
      "host": "localhost",
      "port": 1433,
      "user": "db1user",
      "database": "db1",
      "password": "password",
      "client": "mssql"
    },
    {
      "id": "db2",
      "host": "localhost",
      "port": 1433,
      "user": "db2user",
      "database": "db2",
      "password": "password",
      "client": "mssql"
    }
  ]
}

Configure Path To SQL Database Objects

  1. Copy the SQL files in your project in following folder structure.
 └─ sql
    ├─ schema
    │  ├─ schema1.sql
    │  ├─ schema2.sql
    │  ├─ schema3.sql
    │  └─ ...
    │
    ├─ function
    │  ├─ schema1
    │  │  ├─ function1.sql
    │  │  ├─ function2.sql
    │  │  └─ ...
    │  ├─ schema2
    │  │  ├─ function3.sql
    │  │  ├─ function4.sql
    │  │  └─ ...
    │  ├─ function5.sql
    │  └─ ...
    │
    ├─ procedure
    │  ├─ schema1
    │  │  ├─ procedure1.sql
    │  │  ├─ procedure2.sql
    │  │  └─ ...
    │  ├─ schema2
    │  │  ├─ procedure3.sql
    │  │  ├─ procedure4.sql
    │  │  └─ ...
    │  ├─ procedure5.sql
    │  └─ ...
    │
    └─...

Note: When procedures and functions aren't placed inside a schema folder, they are associated with the default schema.

  1. Create sync-db.yml file in your project folder.
basePath: /path/to/sql

sql:
  - schema/<schema_name>.sql
  - function/<schema_name>/<function_name>.sql
  - procedure/<schema_name>/<procedure_name>.sql

Note: Default basePath is src/sql.

  1. Specify the base path of the folder for SQL files in basePath key.

  2. List database objects in the order they need to be synced under the sql key.

Usage

Add sync-db script in your package.json file.

Add sync-db script in package.json

  1. Add script in your package.json
{
  "scripts": {
    "sync-db": "sync-db",
  }
}
  1. Run
$ yarn sync-db

Usage with npx

  1. Install npx globally on your machine
npm install -g npx
  1. Run
npx sync-db

Sample Projects

  1. Node MSSQL Sample (JavaScript)

License

Licensed under The MIT License.

Keywords

FAQs

Package last updated on 09 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc