GithubHelp home page GithubHelp logo

brunopoeta / db-local-sync Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 2.0 49 KB

DB-Local-Sync lets your local database always in sync with its identical remote database, for development purposes

JavaScript 100.00%
database nodejs mysql

db-local-sync's Introduction

DB-Local-Sync

DB-Local-Sync

What is it?

DB-Local-Sync is a very small nodejs package that keeps your local database in sync with a remote database, for development purposes.

Limitations

Right now, DB-Local-Sync only works with MySQL databases. But I'm already working on MongoDB support.

MySQL strict mode

If you are having some problems while updating your local database, this may be due to the MySQL strict mode.

Just add this to your dbconfig.json and DB-Local-Sync will temporarily disable strict mode.

{
  "strictMode": false, // disable sql strict mode
}

How does it work?

You simply set the configuration file with the local and remote databases and a time interval. It will check every N minutes if there are changes and you will get a notification to update it. That's it.

Install

Install it globally so you can run on your projects:

$ npm install -g db-local-sync

How to use it?

On your working directory, create a dbconfig.json file, like this:

{
  "strictMode": false, // disable sql strict mode
  "interval": 5, // time interval to check for new changes (in minutes)
  
  "local": { // local database settings
    "host": "localhost",
    "user": "root",
    "password": "password",
    "database": "local_db",
    "port": 3306 // default is 3306
  },
  
  "remote": { // remote database settings
    "host": "mysql://remotedatabase",
    "user": "root",
    "password": "password",
    "database": "remote_db",
    "port": 3306 // default is 3306
  }
}

And run this command from the working directory:

$ db-local-sync

You will get something like this:

[DB-Local-Sync] Watching for changes of remote_db in mysql://remotedatabase
[DB-Local-Sync] Database has not changed since last time...

Go on and make some changes on your remote database. After the time interval you've set on the dbconfig.json has passed, you'll get this to pop up on your screen:

Screenshot

Click on it and you're going to sync your local database. You'll get another pop up message saying

Booya! Databases are synced!

If you check your database, you'll see that there's a backup for your local database (in case you run into any problems, you can easily revert) and the changes from the remote database are there on your local database.

TODO

  • MongoDB support
  • Create tests

Contribute

Any help is more than welcome. If you've found any bug, have ideas for new features or want to help in any way, please get in touch!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.