简单的仅转发数据库迁移
ffmigration的Python项目详细描述
ffmigration代表“快速向前迁移”,是一个简单的数据库 迁移程序。
是一种简单而优雅的方法,它将数据库迁移保持在 跟踪wich数据库迁移的各种环境有 已经被处决了。
ffmigration是一个仅向前迁移的工具,这意味着 Ant自动回滚和应用迁移的方法。
工作原理
ffmigration在 选定的数据库以跟踪应用的迁移。这张桌子是 第一次运行时自动创建。
每次运行时,ffmigration都会查找扩展名为.sql的所有文件 在命令行中提供的迁移目录中,检查 迁移文件已应用于数据库,如果尚未应用IH 它应用于数据库并保存到migration_history。
建议将所有迁移文件命名为前缀为数字 为了维持秩序。例如:
$ ls /some/migrations/dir/ 0001_create_some_table.sql 0002_add_some_data.sql 0003_create_index.sql 0004_other_useful_tweaks.sql
限制
这是一个测试版软件,有一些限制:
- By now it only works with MySQL.
安装
使用setup.py:
python setup.py build sudo python setup.py install
或者使用pip:
pip install ffmigrate
命令行
$ ./ffmigration --help Usage: ffmigration [options] database migrations_dir Apply database migrations from migrations_dir to selected database. migration_dir contains files with .sql extension, that are sorted and applied. The applied migrations are saved on a table named 'migration_history' in the selected database Options: --version show program's version number and exit -h, --help show this help message and exit -H HOST, --host=HOST Database server hostname -u USER, --user=USER database username -p ask for a database password --password=PASSWORD database password -P PORT, --port=PORT database connection port -q, --quiet don't print status messages to stdout -l LEVEL, --level=LEVEL logging level (debug,info,warning,error,critical) -n, --noop Do not run commands.