a db migration tool in python
github: nanshens/AQ-DBMigration
pip install aq-dbmigration
config = MigrationConfig("db_name", "db_user", "db_password", "db_host", "db_port", DBConstant.Type.PostgreSQL, "db file path")
db = DBMigration(config)
db.migration()
if you want to skip migration, you can set skip is True in db.migration(), like this:
db.migration(True)
file format: V{version}__{description}.sql
example: V1__test.sql, V2__issue1.sql, V2.1__issue11.sql, V2.12__issue12.sql
version: version = main sequence + . + sub sequence, so order by main first, then sub. example: V1.2 run first and V1.13 second, because 2 < 13.
please start from V1
please use absolute path.
if you use flask, you can set db_path in flask config,
like this app.config['DB_MIGRATION_PATH'] = os.path.join(app.root_path, 'resource', 'db_migration')
and use MigrationConfig("db_name", "db_user", "db_password", "db_host", "db_port", DBConstant.Type.PostgreSQL, app.config['DB_MIGRATION_PATH'])
to init
When used for the first time, it will set the baseline, and subsequent changes will not take effect.
Only read sql files larger than baseline.
- postgresql(tested pass)
- mysql(in testing)
- maria(in testing)
- sqlite(in testing)
This project is licensed under the terms of the GNU General Public License v3.0.