lib/lhm/atomic_switcher.rb in lhm-1.1.0 vs lib/lhm/atomic_switcher.rb in lhm-1.2.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2011, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias +# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias # Schmidt require 'lhm/command' require 'lhm/migration' require 'lhm/sql_helper' @@ -11,11 +11,10 @@ # It should only be used if the MySQL server version is not affected by the # bin log affecting bug #39675. This can be verified using # Lhm::SqlHelper.supports_atomic_switch?. class AtomicSwitcher include Command - include SqlHelper attr_reader :connection def initialize(migration, connection = nil) @migration = migration @@ -34,16 +33,17 @@ "`#{ @destination.name }` to `#{ @origin.name }`" ] end def validate - unless table?(@origin.name) && table?(@destination.name) + unless @connection.table_exists?(@origin.name) && + @connection.table_exists?(@destination.name) error "`#{ @origin.name }` and `#{ @destination.name }` must exist" end end private def execute - sql statements + @connection.sql(statements) end end end