基于阅读网络,堆栈溢出,以及大多数these articles关于从编码恐怖链接的数据库版本控制,我已经做了一个编写计划版本的8岁的PHP数据库的计划mysql网站。
Database Version Control plan
- Create a db as the "Master Database"
- Create a table db_version (id, script_name, version_number, author, comment, date_ran)
- Create baseline script for schema+core data that creates this db from scratch, run this on Master Db
- Create a "test data" script to load any db with working data
- Modifications to the master db are ONLY to be made through the db versioning process
- Ensure everyone developing against the Master Db has a local db created by the baseline script
- Procedures for commiting and updating from the Master Db
- Master Db Commit
- Perform a schema diff between your local db and the master db
- Perform a data diff on core data between your local db and master db
- If there are changes in either or both cases, combine these changes into an update script
- Collect the data to be added to a new row in db_version table, and add an insert for this into the script
- new version number = latest master db version number +1
- author
- comment
- The script must be named as changeScript_V.sql where V is the latest master db version +1
- Run the script against the master db
- If the script executed succesfully, add it to the svn repository
- Add the new db_version record to your local db_version table
- Update from Master Db
- Update your local svn checkout to have all the latest change scripts available
- compares your local db_version table to the master db_version table to determine which change scripts to run
- Run the required change scripts in order against your local db, which will also update your local db_version table
我的第一个问题是,这听起来是否正确? 我的第二个问题是,提交过程似乎有点复杂,每天不止一次。有没有办法可靠地自动化它?或者,我是否应该经常提交数据库更改以使其重要?
答案 0 :(得分:2)
看看你的建议,看起来似乎不可行也不实用。 我在一家公司工作,我们每个数据库使用超过1k个表(非常复杂的系统),这一切都运行得很好:
在这样的环境中,您将拥有多个版本的数据库:
您肯定必须对此进行修改以符合您的情况,但无论如何我认为保留整个数据库的创建脚本的文本版本在可维护性,合并,更新等方面是错误的...... < / p>