views:

71

answers:

2

I'm in the process of starting up a web site project. My plan is to roll out the site in a somewhat rudimentary form first and then add to the site functionality along the way.

I'm using Subsonic 3 for my DAL, and I'm expecting the database will go through multiple versions as the sites evolve. This means I'll need some kind of versioning and migration tools. I understand that Subsonic has built in migration possibilities, but I'm having difficulties grasping how to use these tools, in my scenario.

First there's the SimpleRepository model, where the Subsonic "automagically" handles the migrations as i develop my site. I can see how this works on my dev-machine, but I'm not sure how to handle deployments with this.

  • Would Subsonic run the necessary migrations on my live site as the appropriate methods are called?

  • Is there some way I can force all necessary migrations on a site while taking the site offline, when using the Simplerepository model? (Else I would expect random users to experience severe performance cuts, as the migration routines kick in)

  • Would I be better off using the ActiveRecord model, and then handling migrations with the Subsonic.Schema.Migrator? (I suspect so)

  • Do you know of any good resources explaining how to handle this situation with the migrator? (I read the doc, but I can't piece together how I would use this in practice)

Thanks for listening/replying.

Regards
Jesper Hauge

A: 

i would use activerecord easy to use and any changes you just run the TT files, you would then just build or publish your slution and done ???? SVN will keep your multiple versions of the build stage so if you make a tit of it you just drop back a revision.

minus4
I understand that part of the equation, what I'm after is what is the best way to handle migrations of the database schema. If I change my database layout on my dev machine, and then run the tt-files, I still need to update the database schema on the deployed site, and I'm trying to understand how I can use the Migrator class in Subsonic 3 to handle this process.
Hauge
in that case why dont you have subsonic as a seperate project, then if things change you build and deploy a new DLL
minus4
@minus4 - I can't see how that would help me migrate the database schema on the deployed site.
Hauge
+1  A: 

I would advise against ever running migrations against a live site. SubSonic's migrations are really there to make development simpler and should never be used against a live environment. To be honest even using SubSonic.Schema.Migrator you're still going to bump into the fact that refactoring databases is an incredibly hard problem. For example renaming a column in a table using management studio is trivial, but what happens in the background involves creating an entirely new table and migrating all the constraints, data etc. before renaming the new table. The most effective way I've found for dealing with this is:

  1. Script all database changes as you make them in your development environment (SQL Server Management Studio will do this for you) and add these scripts to your source control.
  2. As part of deployment (obviously backup first) run the migration scripts and then deploy the updated application on success.

Whether you use ActiveRecord or SimpleRepository is then down to whether you want the extra features/complexity of ActiveRecord.

Hope this helps

Adam