Skip to content

Instantly share code, notes, and snippets.

@JamesPaden
Last active March 5, 2019 17:11
Show Gist options
  • Save JamesPaden/64f424697e01f8f4fbfa2bb6eb07a240 to your computer and use it in GitHub Desktop.
Save JamesPaden/64f424697e01f8f4fbfa2bb6eb07a240 to your computer and use it in GitHub Desktop.
module ActiveMigrator
class ActiveMigratorDestinationModel < ActiveRecord::Base
self.abstract_class = true
# disable STI for this "copy" model
self.inheritance_column = :_type_disabled
establish_connection DB_ACTIVE_MIGRATOR_CONFIGURATION[:destination]
end
end
module ActiveMigrator
module ActiveMigratorSource
extend ActiveSupport::Concern
included do
@active_migrator_destination_klass_name = "ActiveMigrator::#{self.name}ActiveMigratorDestinationModel"
eval <<-STR, nil, __FILE__, __LINE__
ActiveMigrator.send(:remove_const, :#{self.name}ActiveMigratorDestinationModel) if defined?(#{@active_migrator_destination_klass_name})
class #{@active_migrator_destination_klass_name} < ActiveMigrator::ActiveMigratorDestinationModel
self.table_name = '#{table_name}'
self.record_timestamps = false
self.lock_optimistically = false
end
STR
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment