Schema migration made easy
Project description
dbschema is a tool to run MySQL or PostgreSQL migrations automatically. Using a table, it keeps a state of previous migrations to avoid duplicates.
Features:
Support for MySQL and PostgreSQL
Optional pre and post-migration queries (for example to update privileges)
Multiple migrations in multiple databases can be processed as one.
Installation
Install dbschema
pip3 install dbschema
Create a config file
Create the file ~/.dbschema.yml and add your databases configuration. See example
Create migrations table
dbschema uses a table called migrations_applied to keep track of migrations already applied to avoid duplication. See the schema for MySQL or PostgreSQL.
Migrations folder structure
For each database, you need to have a migration path (setting path in the migration file).
Within that path you need to create one folder per migration. This folder needs to contain a file called up.sql with the SQL queries.
/path/to/migrations/db1/ |-- migration1/ | |-- up.sql |-- migration2/ | |-- up.sql |... /path/to/migrations/db2/ |-- migration1/ | |-- up.sql |-- migration2/ | |-- up.sql |...
Usage
dbschema
# or
dbschema --config /path/to/config.yml
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
Built Distribution
Hashes for dbschema-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d435e404ea102413d0cc0fa10e08c79b7faf38bcc510adcfb4eba42df1fb218 |
|
MD5 | b925f71f489c911fad93f9d3da30936a |
|
BLAKE2b-256 | 4f6620dfb8d7062f4747269f03917aa4ac7d41baa4d272a0c81cda173be521d0 |