A command line utility
Project description
database-migration-tool
Database migration made simple.
Database support
- MySQL
- SQLite
Functions
Validations
- Only run sql querys that has not been run before
- Checks that all checksum are same on installed and on the scripts
- New versions can't be inserted between two installed scripts
Command line
<command> --changelog-file=config.yaml migrate
commands:
command | Description |
---|---|
clean | |
info | |
migrate |
Changelog file
yaml file with changelog settings for the database migrations
example.yaml
database:
database_plugin: mysql
host: localhost
port: 3306
username: ${env:MYSQL_USER}
password: ${env:MYSQL_PASS}
xxxxxxxx:
allow_clean: True
databaseMigrations:
- changeSet: 1
author: Mike <mike@email.com>
changes:
sqlFile: baseline.sql
- changeSet: 2
author: Matt <matt@email.com>
changes:
sqlFile: test.sql
parameters:
- userName: test
- email: test@email.com
- changeSet: 3
author: Matt <matt@email.com>
changes:
scriptFile: test.py
parameters:
- tableName: users
- name: test
baseline.sql
--- sql with parameter inputs from changelog file
CREATE TABLE ${tableName} (
name VARCHAR(30) NOT NULL,
PRIMARY KEY(name)
);
INSERT INTO ${tableName} (name) VALUES ('${name}');
--- sql with parameter input from enviroment variables
CREATE TABLE ${env:TABLE_NAME} (
test VARCHAR(10) NOT NULL,
PRIMARY KEY(test)
);
--- normal sql
CREATE TABLE email (
email VARCHAR(255) NOT NULL,
PRIMARY KEY(email)
);
Tables
database-change-log
Table for tracking changes to the database
Column | Data type | Description |
---|---|---|
id | INT | ID |
description | VARCHAR(255) | description from the script |
script | VARCHAR(255) | filename of the script |
checksum | VARCHAR(64) | SHA256 checksum of the script file |
installed_on | TIMESTAMP | date and time when successfully migrtated |
total_querys | INT | total sql querys in file |
done_querys | INT | number of last successful query |
success | INT | 1 for success 0 for failure |
database-change-lock
Table for storing database lock to prevent only one instanse of xxx to be running against the database
Column | Data type | Description |
---|---|---|
id | INT | ID of the lock |
locked | INT | 1 if locked otherwise 0 |
granted | DATETIME | Date and time lock was granted |
locked_by | VARCHAR(255) | DB username |
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
db-migration-tool-0.1.1.tar.gz
(20.6 kB
view details)
Built Distribution
File details
Details for the file db-migration-tool-0.1.1.tar.gz
.
File metadata
- Download URL: db-migration-tool-0.1.1.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b4e4e893b77d1696908184ddefce9e2714ff9467f7ed1883066d932b7371f6e |
|
MD5 | 28f09a90f1f23295b16d06d66f2df04f |
|
BLAKE2b-256 | 0818d25d2153edf2b0bb6da2113616bb629d531e3b6dc8a4a79e8daf5588d34b |
File details
Details for the file db_migration_tool-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: db_migration_tool-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebf94a596014282b32f8b65fb363bc920fa109222086017aa4424237e15c48a9 |
|
MD5 | 2e559c38772652b4aff087b92a20a9e1 |
|
BLAKE2b-256 | 36694a829000b24f646e3b4e89e8b099fce386cfdef044d2d01449ed619a7cb9 |