Skip to main content

Database Upgrading Tool

Project description

# dbupgrade ## Database Upgrading Tool

[![License](https://img.shields.io/pypi/l/dbupgrade.svg)](https://pypi-hypernode.com/pypi/dbupgrade/) [![GitHub Release](https://img.shields.io/github/release/srittau/dbupgrade/all.svg)](https://github.com/srittau/dbupgrade/releases/) [![pypi](https://img.shields.io/pypi/v/dbupgrade.svg)](https://pypi-hypernode.com/pypi/dbupgrade/) [![Travis CI](https://travis-ci.org/srittau/dbupgrade.svg?branch=master)](https://travis-ci.org/srittau/dbupgrade)

Usage: dbupgrade [OPTIONS] [-l API_LEVEL|-L] DBNAME SCHEMA DIRECTORY

Upgrade the given SCHEMA in the database specified as DBNAME with SQL scripts from DIRECTORY. DIRECTORY is searched for all files with the “.sql” suffix. These files are SQL scripts with a special header sections like this:

-- Schema: my-db-schema
-- Version: 25
-- API-Level: 3
-- Dialect: postgres

CREATE TABLE ...

The following headers are required:

Schema:

Name of the schema to update.

Dialect:

Database dialect of this script. Use SQLalchemy’s database URL scheme identifier, e.g. postgres or sqlite.

Version:

The new version of the schema after this script was applied. It is an error if two scripts have the same schema, dialect, and version.

API-Level:

The new API level of the schema after this script was applied. For a given schema, the API level of a subsequent version must either be equal or higher by one than the API level of the preceding version. For example, if script version 44 has API level 3, script version 45 must have API level 3 or 4.

The database must contain a table db_config with three columns: schema, version, and api_level. If this table does not exist, it is created. This table must contain exactly one row for the given schema. If this row does not exist, it is created with version and api_level initially set to 0.

The current version and API level of the schema are requested from the database and all scripts with a higher version number are applied, in order. If there are any version numbers missing, the script will stop after the last version before the missing version.

Unless the -l or -L option is supplied, only scripts that do not increase the API level will be applied. If the -l option is given, all scripts up to the given API level will be applied. -L will apply all scripts without regard to the API level.

Each script is executed in a seperate transaction. If a script fails, all changes in that script will be rolled back and the script will stop with an error message and a non-zero return status.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dbupgrade-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file dbupgrade-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dbupgrade-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1abe3c206bc342333864b8ad69c25d31bdc4e385d040f47b491d1c2c87ce143c
MD5 62b26f0594957a39f99f49f68f9c97f3
BLAKE2b-256 f844195640c5ecd443583897c51202739524656672ff2b27e3cf985aa5e7389a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page