-
Notifications
You must be signed in to change notification settings - Fork 4
DBVersion
Category:Databases Category:Versioning
DBVersion is a database versioning tool, used to keep track of database changes. It can also be used to make sure your development and production database are synchronized![h2]Installation instructions[/h2] [b]1.[/b] Download DBVersion here: File:dbversionci-0.9.zip, unzip contents to the application folder.
[b]2.[/b] Dump your current database structure to a file, it will be version 0 of the DB.
[b]3.[/b] Create a XML file that will be used to store the changes you make. Here's a template file with full syntax: [code] <?xml version="1.0" encoding="UTF-8"?> <!-- Actions --> <![CDATA[ INSERT INTO table (col1,col2) VALUES ... ]]>
<version id="2">
<dropColumn name="table.column" />
</version>
[b]6.[/b] Execute a Dry run of the library, testing what the sql output looks like. Here's an example (from a controller) how to run it: [code] $this->load->library('CIDBVersion'); $this->cidbversion->DryRun(); [/code] [b]7.[/b] If the xml validates and the output looks good, get ready to update! It's very simple as well, here's a code snippet: [code] $this->load->library('CIDBVersion');
if(!$this->cidbversion->LatestDBVersion()) { $this->cidbversion->Synchronize(); } [/code] As you see, the LatestDBVersion() method can be used to test if the DB is up-to-date.
[b]8.[/b] For every new version you make on your database, update the XML file with a new version element, and corresponding actions. Also, update the dbversion table with a new version field.
[b]9.[/b] All you need to do to synchronize another database with the DBVersion library installed is just to send the updated XML file to that server, and run Synchronize() there. [h3]Forum discussion[/h3] The forum thread for DBVersion is here:[url=http://codeigniter.com/forums/viewthread/69303/]http://codeigniter.com/forums/viewthread/69303/[/url], please post your comments, ideas or other things. Thank you!