lib/lhm/migrator.rb in lhm-1.1.0 vs lib/lhm/migrator.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' @@ -140,35 +140,32 @@ end private def validate - unless table?(@origin.name) + unless @connection.table_exists?(@origin.name) error("could not find origin table #{ @origin.name }") end unless @origin.satisfies_primary_key? error("origin does not satisfy primary key requirements") end dest = @origin.destination_name - if table?(dest) + if @connection.table_exists?(dest) error("#{ dest } should not exist; not cleaned up from previous run?") end end def execute destination_create - sql(@statements) + @connection.sql(@statements) Migration.new(@origin, destination_read) end def destination_create - original = "CREATE TABLE `#{ @origin.name }`" - replacement = "CREATE TABLE `#{ @origin.destination_name }`" - - sql(@origin.ddl.gsub(original, replacement)) + @connection.destination_create(@origin) end def destination_read Table.parse(@origin.destination_name, connection) end