[rspec-users] Spec migrations?

Harm Aarts harm.aarts at innovationfactory.nl
Fri Apr 25 08:57:14 EDT 2008

Dear list,

I am in the process of writing on an app with is already running. I  
need to create a couple of structural database changes for which I use  
migrations. However I want to be absolutely sure I do not destroy any  
existing data. So RSpec is the way to go! Or so I thought.
1. dropped the test database.
2. create the database.
3. migrate to the version just before the critical migration
4. insert some stuff in the database
5. run the critical migration
6. see if the result is as I expected

But I receive the following error:
Mysql::Error: #HY000Lock wait timeout exceeded; try restarting  
transaction: ALTER TABLE `members` DROP `manager`

And I do not know if this is the way forward. Does any one have any  
(relevant) thoughts on this?

With kind regards,

PS the actual spec:

describe Member, "should migrate properly" do
   it "should migrate correctly from a column manager to a role  
manager" do

     `rake db:drop`
     `rake db:create`
     `rake db:migrate VERSION=59`
     m1 = Member.new(:manager => true)
     m2 = Member.new(:manager => true)
     m3 = Member.new(:manager => true)
     `rake db:migrate VERSION=60`
     Member.find(m1.id).has_role?("manager").should be_true
     Member.find(m2.id).has_role?("manager").should be_true
     Member.find(m3.id).has_role?("manager").should be_true

More information about the rspec-users mailing list