module Cardio::Migration::Port
methods for porting migrations from old table to new table
Public Instance Methods
port()
click to toggle source
# File lib/cardio/migration/port.rb, line 11 def port return unless lease_connection.table_exists? old_deck_table rename_old_tables lease_connection.execute "INSERT INTO #{table} (#{select_nonduplicate_versions})" lease_connection.drop_table old_deck_table end
port_all()
click to toggle source
# File lib/cardio/migration/port.rb, line 5 def port_all %i[schema transform].each do |type| migration_class(type).port end end
Private Instance Methods
lease_connection()
click to toggle source
# File lib/cardio/migration/port.rb, line 32 def lease_connection ActiveRecord::Base.lease_connection end
rename_old_tables()
click to toggle source
# File lib/cardio/migration/port.rb, line 25 def rename_old_tables old_tables.each do |old_table_name| next unless lease_connection.table_exists? old_table_name lease_connection.rename_table old_table_name, table end end
select_nonduplicate_versions()
click to toggle source
# File lib/cardio/migration/port.rb, line 20 def select_nonduplicate_versions "SELECT * FROM #{old_deck_table} o WHERE NOT EXISTS " \ "(SELECT * FROM #{table} n WHERE o.version = n.version)" end