Giter Site home page Giter Site logo

dbsync's Introduction

dbsync

A very simple way to implement git's built-in hook feature to sync up local database changes with other collaborator's local databases.

##requirements

  1. mysql (either installed globally or through server packs like XAMPP, LAMP, WAMP, MAMP, AMPPS, etc.)
  2. executing shell scripts

##how to use

  1. Clone this repo
  2. Copy dbsync folder into the repo you want to sync
  3. Open config.sh to - you guessed it - configure your settings! (should be pretty self-explanatory)
  4. From your repo run: bash dbsync/install.sh
  5. After your configuration has been set it is recommended that you run git update-index --assume-unchanged dbsync/config.sh so that you and your other collaborators aren't fighting over settings and yours can remain unique to your system.

This will add two files to your .git/hooks folder. A pre-commit for before you actually commit your changes to the remote, and post-merge for whenever you make a pull from remote. Each commit will make a database dump of you local db (specified in config.sh) and each pull will take the generated dbdump.sql file from the repo and sync to your local db. This was the simplest and most generic way I could think to keep local databases in sync using git. I would love to hear other recommendations. I have not tested this method with large databases and I can only guess that the performance would take a bigger hit the bigger the database.

##hooks inside...hooks (??) There may be cases when you need to actually do more then this basic implementation provides. These hooks will allow you to do just that (hopefully). In the config.sh file there are 4 variables confusingly - yet appropriately - named so that you can define your own hooks before and after the git hooks run. In case the dbsync hooks just aren't good enough for your needs, you can place any shell command inside the variables (that's the idea anyway) to run either before or after each hook.

  1. prePreCommitHook: ran before the pre-commit git hook runs it's default tasks.
  2. postPreCommitHook: ran after the pre-commit git hook has run it's default tasks.
  3. prePostCommitHook: ran before the post-commit git hook has run it's default tasks.
  4. postPostCommitHook: ran after the post-commit git hook has run it's default tasks.

Note: This is unverified but my guess is that the hooks defined with relative file paths will be relative to the git hooks they are called in rather than the config.sh files are were defined in.

dbsync's People

Stargazers

Brooks Ilg avatar

Watchers

Micah Iriye avatar

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.