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.
- dropped the test database.
- create the database.
- migrate to the version just before the critical migration
- insert some stuff in the database
- run the critical migration
- 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
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
`rake db:drop` `rake db:create` `rake db:migrate VERSION=59` m1 = Member.new(:manager => true) m1.save_with_validation(false) m2 = Member.new(:manager => true) m2.save_with_validation(false) m3 = Member.new(:manager => true) m3.save_with_validation(false) `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