Reputation:
Is there any integrated solution for this?
Would it work if I create a folder called mysql and dump sql there every time I do major changes?
Subversion is perfect but how do you deal with db part? Can someone please explain their workflow.
Thanks!
Upvotes: 1
Views: 522
Reputation: 736
I'm using simple batch files to export/import any changes to/from DB. Just created additional folder _db with following files:
import.bat:
if exist c:\mysql\bin\mysql.exe goto work1
exit
:work1
C:\mysql\bin\mysql.exe -u root --default-character-set=utf8<C:\project\_db\dbName_dc.sql
C:\mysql\bin\mysql.exe -u root -D dbName --default-character-set=utf8<C:\project\_db\dbName.sql
pause
exit
export.bat
if exist c:\mysql\bin\mysql.exe goto work1
exit
:work1
C:\mysql\bin\mysqldump.exe -u root --default-character-set=utf8 dbName>C:\project\_db\dbName.sql
C:\mysql\bin\mysqldump.exe -u root -d --default-character-set=utf8 dbName>C:\project\_db\dbName_struct.sql
pause
exit
dbName_dc.sql
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
DROP DATABASE IF EXISTS `dbName`;
CREATE DATABASE `dbName`;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
It's not a problem to write similar files for unix like systems.
Upvotes: 2
Reputation: 28245
Ruby on Rails uses a technique called migrations to keep track of changes in the database schema. It creates automatically a file named development_structure.sql
(if it does not exist you can create it for example by calling rake db:structure:dump). If you would submit or check in this file in SVN each time you make a major change, you would have stored your database changes in SVN. It contains CREATE TABLE commands like the following:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(255) NOT NULL,
`email` varchar(255) DEFAULT NULL,
..
)
Upvotes: 1
Reputation: 308763
You might want to read about what Scott Ambler and ThoughtWorks did about agile databases and see what you think:
Upvotes: 1