Skip to content
DBgit edited this page Jul 15, 2019 · 36 revisions

Principles

DBGit is intended for support of DB development processes and methods as close to those of Git as possible:

  • easy-to-create sandboxes, individual for each developer;
  • new branches for new features/fixes;
  • CI/CD, and others.

Similar to Git, you can switch between commits as needed, and get the consistent db state, including table structure and records, views, fuctions and other db objects. The price of this flexibility is that you will need one db/schema for each DBGit installation: each developer will get one db/schema for his/her sandbox, and each test/production deployment instance will also get one. If you plan to use per-branch sandboxes, or any other Git usage method, you can do it.

DBGit supports Oracle, PosgreSQL, and is intended to support other DBMS. It even provides cross-DBMS features to some extent (to be extended in the future releases).

Quick start

Install or build from sources DBGit.

First thing you need to do is to create git repository and bind dbgit with database. To create repository you can use one of next options:

dbgit clone https://login:password@example.com/repo.git

It does the same as git clone, it clones remote repository to your computer. Or you can run

dbgit init
dbgit remote add origin https://login:password@example.com/repo.git

These commands will create empty local repository and after that will bind it with remote repository.

To bind your database with dbgit you need to run dbgit link with command like this:

dbgit link jdbc:oracle:thin:@192.168.1.1:1521:SCHEME user=username password=pass
dbgit is ready to use!

If you are using Oracle Database, make sure your Oracle user have grants to next tables:

  • DBA_ROLE_PRIVS
  • DBA_OBJECTS
  • DBA_SEQUENCES
  • DBA_TABLES
  • DBA_TAB_COLS
  • DBA_USERS
  • DBA_SEGMENTS

More on all the commands

These are common Dbgit commands used in various situations:

Start a working area

clone clone a repository into a new directory
init create an empty Git repository or reinitialize an existing one
link establishes connection with database
synonym specifies synonym for db scheme
remote let you bind your local repository with remote repository

Work on the current change

status shows current status of db objects
add adds db objects into the dbgit index
reset reset current HEAD to the specified state
rm removes objects from the dbgit index
restore restores db from the dbgit repository
dump dumps db objects into the dbgit repository

Grow, mark and tweak your common history

valid checks if dbgit data files are valid
checkout switch branches or restore working tree files
commit makes git commit
merge join two or more development histories together

Gollaborate

pull fetch from and integrate with another repository or a local branch
push update remote refs along with associated objects
fetch download objects and refs from another repository