SubSonic Forums
All Your Database Are Belong To Us

Migrations with SQL

Latest post 05-20-2008 9:39 AM by dsapala. 3 replies.
  • 05-17-2008 9:30 AM

    Migrations with SQL

    How would I go about using sql files for migrations instead of using code?  I have an existing project that already has sql files to migrate the database.  I don't want to have to recreate the schema with code if I don't have to.  Thank you in advance. 

  • 05-19-2008 3:32 PM In reply to

    Re: Migrations with SQL

    I'm not sure I understand... don't use Migrations if you don't want to I spose...?

     

    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us!

  • 05-19-2008 6:30 PM In reply to

    Re: Migrations with SQL

    If you don't want to recreate the sql as migrations then the best way would be to use your sql files like you normally do and then start using migrations after that.

    Part of a migrations power is that you can revert the changes by going down a version, so unless you have matching "undo" sql scripts finding a way to pipe your existing sql through migrations without really re-writing them would be more headaches than they are worth.

    That said there is an Execute() method that you can use to execute arbitraty sql, but that's usually for smaller blocks of sql, not large chunks.  If you do abuse the system that way :) then I'd suggest making a matching Down() that undoes whatever your raw sql is doing.

  • 05-20-2008 9:39 AM In reply to

    Re: Migrations with SQL

    Thanks for the quick replies!  I am a rails lover, but I can't use it for this project.  So I do understand the "ups" and "downs" of it. ;-)

    I was planning on making down methods for the already existing sql create scripts if I can just get past one little tiny issue.

    I am using the aspnet schema for membership and roles.  It has a particularly large sql script that has a lot of declared variables and whatnot.  I did try using the Execute() method, but I got errors about variables already being declared and stuff.  I was hoping there was another method available that I was overlooking.  I suppose I'll have to automate the sqlcmd program in the background to handle that particular migration.

    Any thoughts?

     

Page 1 of 1 (4 items) | RSS