禁欲主义的数据库迁移。使用原始数据库迁移来增强python应用程序的最简单方法
amigrations的Python项目详细描述
安装
只需在bash中运行:
pip install amigrations
用法
fromamigratonsimportAMigrationsamigrations=AMigrations('mysql://root:123456@localhost:3306/amigrations_test',path_to_folder_with_migrations)files_created=amigrations.create(migraiton_message)# files_created is a dictionary with two keys: up and down. If you want immediately update migration content, please# do followingwithfiles_created['up'].open('w')asfpu,files_created['down'].open('w')asfpd:fpu.write('CREATE TABLE test (id int(11) not null AUTO_INCREMENT, PRIMARY KEY(id))')fpd.write('drop table test')# run db upgradeamigrations.upgrade()# please pass migration id you want to downgrade to, includingamigrations.downgrade_to(downgrade_to_id)