Skip to content
rocket-3 edited this page Apr 17, 2020 · 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;
  • easy-to-create branches for new features/fixes/developers/versions;
  • 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, functions and other db objects. DB migrations between commits are automatic.

DBGit supports Oracle, PostgreSQL, and is intended to support other DBMS in the future. It even provides cross-DBMS features to some extent: you can migrate table structure and data between different DBMSs, if needed.

Quick start

Install or build from sources DBGit (Windows / macOS / Linux).

First thing you need is a local Git repository, which you create as you would do it with Git:

  • clone an existing remote repository locally:

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

  • create an empty local repository and bind it with the remote one:

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

Then bind the repository to DB:

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 select privileges to the next system views:

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

More on all the commands

All commands have the general behaviour:

  • You can run any command with -v option, it will show you full log of command execution then.
  • You can create and config file .dbignore to ignore some of database objects .dbignore must be placed in repository .dbgit directory.

Lets you exclude any of db objects from the work process. If name of db object will be mathed of regular expression you will write in this file it will be missed by the dbgit. Also, if you will write ! as a first character of row, db object will be processed even if the one was excluded by previous expressions. .dbignore creates automatically when you run dbgit link command.

By default .dbignore lets you work with your db user scheme only, and it ignores all table data. You can reconfigure it at any time.

Start a working area
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
link Establish connection with database
synonym Specify synonym for db scheme
remote Let you bind your local repository with remote repository
config Let you configure DBGit
Work on the current change
status Show current status of db objects
add Add db objects into the DBGit index
reset Reset current HEAD to the specified state
rm Remove objects from the DBGit index
restore Restor db from the DBGit repository
dump Dump db objects into the DBGit repository
Grow, mark and tweak your common history
valid Check if DBGit data files are valid
checkout Switch branches or restore working tree files
commit Make Git commit
merge Join two or more development histories together
Collaborate
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