Package: database-version-control
DVCA Database Version Control (DVC) tool written in Python.More informationGitHubDockerHubReadthedocsYoutubeKey FeaturesCommand line interfaceRich Database metadataDatabase Upgrade and DowngradeFlexible Configuration FormatVia Environment VariablesVia Configuration FileDeploymentAs a Commandline toolExecutables on github releaseshttps://github.com/kenho811/Python_Database_Version_Control/releasesThe releases page provides executables on the below three Operating Systems.Mac (Latest)Linux Ubunutu (Latest)Windows (Latest)if you happen to use one of the OSes listed above, you can download the executable directly and use it without installing python!Python Library on PyPIhttps://pypi.org/project/database-version-control/If you have python and pip installed, you can download the command line tool from PyPI!# Install the library from PyPi
pip install database-version-control

# To get more instructions of the commandline tool, run the below in the terminal
dvc --helpAs a MicroserviceImage on Dockerhubhttps://hub.docker.com/repository/docker/kenho811/database-version-control#Run the below to see it in action# Clone the repo and checkout release branch
git clone -b release git@github.com:kenho811/Python_Database_Version_Control.git 

# cd to the repository
cd Python_Database_Version_Control/docker_compose_demo

# Fnd the docker-compose.yml and run 
docker compose up

# Using psql as client, access the postgres DB and see the result
(URL: postgres://test:test@localhost:5433/test)
PGPASSWORD=test psql -U test -d test -h localhost -p 5433

# Check out docker-compose.yml file for usage as a microserviceDevelopment-Testing-release workflow# Git clone the repo and checkout master
git clone -b master git@github.com:kenho811/Python_Database_Version_Control.git 

# create a feature branch
git checkout -b feature/{code_change_theme}

# Pip install dependencies
pip install with `pip install ".[dev]"`

# Enable local githooks
git config --local core.hooksPath .githooks/

# Development

# Write unit + integration tests

# Run pytest
pytest

# Generate Documentation locally. ISLOCAL=1 removes local dependencies.
cd docs
ISLOCAL=1 make clean html

# Open PR against master

# (By maintainer) For a new release, cut a new release branch with version number (match app version number). 
git checkout -b release/{app_version_number}CI conventionThe below is currently triggered via Github ActionBranchTestingDockerHub tagDockerhub ReadmePyPI versionReadthedocs versionmasterYeslatestYesN/Alatestrelease/{major.minor}YesN/AN/AN/AN/AfeatureYesN/ANoN/Afeature-docTagDockerHub tagDockerhub ReadmePyPI versionReadthedocs versionrelease/{major.minor.patch}release-{major.minor.patch}No{major.minor.patch}release-{major.minor.patch}Technical DetailsDatabase supportedPostgresSupport for other databases will be added soon....Database instructions format supportedSQL filesSQL files naming conventionAll SQL files are consideredrevision filesThey must follow the patternRV[0-9]*__.*\.(upgrade|downgrade)\.sql. In words, it meansThey start with the prefixRVAfterRV, it follows an arbitrary revision number (e.g. RV1, RV2, RV3 etc. etc.)AfterRV(arbitrary_revision_number), it follows double underscores and an arbitrary number of characters. Everything after__describes what the SQL file does.AfterRV(arbitrary_revision_number)__(description), it follows a dot and the character group of eitherupgradeordowngrade. 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.AfterRV(arbitrary_revision_number)__(description).(upgrade/downgrade), it follows a dot and the character group ofsql.Overall,RV(arbitrary_revision_number)__(description).(upgrade/downgrade).sqlExample SQL revision filesRV1__create_scm_company_secrets_and_tbl_earnings.upgrade.sqlRV1__delete_scm_company_secrets_cascade.downgrade.sqlRV2__alter_scm_company_secrets_tbl_earnings_updated_at_add_index.upgrade.sqlRV2__alter_scm_company_secrets_tbl_earnings_updated_at_remove_index.downgrade.sqlDatabase MetadataSchema dvc will be createdTable dvc.database_revision_history will be created.Table dvc.database_version_history will be created.User InterfaceCLIMade with PythonTyperLibraryEntrypoint isdvcSample commands aredvc version--> Show versiondvc cfg--> Configuration related commandsdvc cfg init--> Generate configuration filesdvc 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 tablesdvc db downgrade---> Apply Database Downgrade Revisiondvc db downgrade --mark-only---> Only mark to metadata tablesdvc db current---> Current Database Versiondvc db ping--> Ping database connection