A library for doing database version control
Project description
Python library to do database version control.
PyPi
See: https://pypi.org/project/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 version
--> Show versiondvc cfg
--> Configuration related commandsdvc cfg init
--> Generate configuration files
dvc db
--> Database related commandsdvc db init
--> Initialise the database with metadata schema and tablesdvc db upgrade
---> Apply Database Upgrade Revision and mark to metadata tablesdvc db upgrade --mark-only
---> Only mark to metadata tables
dvc db downgrade
---> Apply Database Downgrade Revisiondvc db downgrade --mark-only
---> Only mark to metadata tables
dvc db current
---> Current Database Versiondvc db ping
--> Ping database connection
dvc sql
--> SQL related commandsdvc sql generate --from-sql-folder
--> Generate RV files from all SQL files in a given folder
- 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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa2e98bfc8e4a0b91c1d8de9de5680e858c48910ea18413e40473a9ff57bfb5 |
|
MD5 | a2af569ec4b23ebfea5f6aa7ee7f7590 |
|
BLAKE2b-256 | fde4531b452d9c576a30b8841c007dd56587a06971e0027166d7c7e746e5b026 |