A library for doing database version control
Project description
Python library to do database version control.
Demonstration
See: https://www.youtube.com/watch?v=9l3m7zBxN4Y
Usage
- Git clone the repository. Cd into the repository.
- pip install with
pip install .
- Run
dvc --help
in the terminal to see further instructions.
Development
- Git clone the repository. Cd into the repository.
- pip install with
pip install .[dev]
(in zsh, dopip install .'[dev]'
) - use
pytest
to run tests
Details
Database supported
- Postgres Database
Database instructions format supported
- SQL files
SQL files naming convention
- All SQL files are considered
revision files
- They must follow the pattern
RV[0-9]*__.*\.(upgrade|downgrade)\.sql
. In words, it means- They start with the prefix
RV
- After
RV
, it follows an arbitrary revision number (e.g. RV1, RV2, RV3 etc. etc.) - After
RV(arbitrary_revision_number)
, it follows double underscores and an arbitrary number of characters. Everything after__
describes what the SQL file does. - After
RV(arbitrary_revision_number)__(description)
, it follows a dot and the character group of eitherupgrade
ordowngrade
. When applied, an upgrade revision file will move the database version upward by 1, while a downgrade revision file will move the database version downward by 1. - After
RV(arbitrary_revision_number)__(description).(upgrade/downgrade)
, it follows a dot and the character group ofsql
. - Overall,
RV(arbitrary_revision_number)__(description).(upgrade/downgrade).sql
- They start with the prefix
- Example SQL revision files
- RV1__create_scm_company_secrets_and_tbl_earnings.upgrade.sql
- RV1__delete_scm_company_secrets_cascade.downgrade.sql
- RV2__alter_scm_company_secrets_tbl_earnings_updated_at_add_index.upgrade.sql
- RV2__alter_scm_company_secrets_tbl_earnings_updated_at_remove_index.downgrade.sql
Metadata
- Schema dvc will be created
- Table dvc.database_revision_history will be created.
- Table dvc.database_version_history will be created.
User Interface
- CLI
- Made with Python
Typer
Library- Entrypoint is
dvc
- Sample commands are
dvc cfg init
--> Generate configuration filesdvc db init
--> Initialise the database with metadata schema and tablesdvc db upgrade
---> Apply Database Upgrade Revisiondvc db downgrade
---> Apply Database Downgrade Revisiondvc db current
---> Current Database Versiondvc db ping
--> Ping database connection
- Entrypoint is
- Made with Python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for database_version_control-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec6f4b4871698b66b5e4e3aff61eaf6b20316f872023f39901854cd44e90d56 |
|
MD5 | a59633f9e3ba61f73f8fa97591cc5d02 |
|
BLAKE2b-256 | 7fa7e72df77ebae162186c17afd809a56558c8edfd57cf9a6e2e15dc1acf352a |