Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL scripts under Subversion

I am a build engineer and responsible for our source control layout. We need to keep a version of all database objects and also group changes together with rollback scripts for pushes to production. We have development, QA, and Production environments and there are different versions of the database objects in each. One area we have trouble is with table creates vs alters. Developers will check in alters but to recreate the database we need the creates. Any ideas would be appreciated.

like image 719
Jeremy E Avatar asked Jun 05 '09 19:06

Jeremy E


People also ask

What are SQL scripts?

What is SQL Scripts? A SQL script is a set of SQL commands saved as a file in SQL Scripts. A SQL script can contain one or more SQL statements or PL/SQL blocks. You can use SQL Scripts to create, edit, view, run, and delete script files.

What database does Subversion use?

For storing the repository contents, Subversion uses its own FSFS database. It's not a database in the relational database sense. It's a filesystem-based method of storing repository contents. For some server-side functionality, and for storing working copy metadata on the client end, it uses SQLite.

How do I run a SQL Server script?

Click Query > Connection > Connect to connect to the server that contains the database you want to access. Select the appropriate StarTeam Server database. Open the tuning script, by choosing File > Open > foldername\scriptname. Execute the script, by clicking the Execute button on the toolbar or by pressing F5.


2 Answers

I'm a huge fan of http://www.liquibase.org/. It allows you to track versions of your database, including the ability to "update" and "rollback" your schema/data.

They have a nice XML syntax that has baked in support for common refactorings, including ones detailed in http://databaserefactoring.com/

They also have Eclipse plugins to help create the change scripts, and ant task's for integrating into your build.

My only complaint is that it is Java based and I'm fond of installing java on my build server for .NET projects. In that case I've heard good things about http://code.google.com/p/migratordotnet/.

like image 123
nikmd23 Avatar answered Oct 02 '22 00:10

nikmd23


You should look into how frameworks like rails handle migrations

http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations

like image 26
marcgg Avatar answered Oct 01 '22 23:10

marcgg