spec/integration/lhm_spec.rb in lhm-2.0.0 vs spec/integration/lhm_spec.rb in lhm-2.1.0
- old
+ new
@@ -1,12 +1,10 @@
# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt
require File.expand_path(File.dirname(__FILE__)) + '/integration_helper'
-require 'lhm'
-
describe Lhm do
include IntegrationHelper
before(:each) { connect_master! }
@@ -200,9 +198,31 @@
table_read(:small_table).columns["id"].must_equal({
:type => "int(5)",
:is_nullable => "NO",
:column_default => "0"
})
+ end
+ end
+
+ it "works when mysql reserved words are used" do
+ table_create(:lines)
+ execute("insert into `lines` set id = 1, `between` = 'foo'")
+ execute("insert into `lines` set id = 2, `between` = 'bar'")
+
+ Lhm.change_table(:lines) do |t|
+ t.add_column('by', 'varchar(10)')
+ t.remove_column('lines')
+ t.add_index('by')
+ t.add_unique_index('between')
+ t.remove_index('by')
+ end
+
+ slave do
+ table_read(:lines).columns.must_include 'by'
+ table_read(:lines).columns.wont_include 'lines'
+ index_on_columns?(:lines, ['between'], :unique).must_equal true
+ index_on_columns?(:lines, ['by']).must_equal false
+ count_all(:lines).must_equal(2)
end
end
describe "parallel" do
it "should perserve inserts during migration" do