Class: PactBroker::DB::DataMigrationTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/pact_broker/tasks/data_migration_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ DataMigrationTask

Returns a new instance of DataMigrationTask.



20
21
22
# File 'lib/pact_broker/tasks/data_migration_task.rb', line 20

def initialize &block
  rake_task(&block)
end

Instance Attribute Details

#database_connectionObject

Returns the value of attribute database_connection.



18
19
20
# File 'lib/pact_broker/tasks/data_migration_task.rb', line 18

def database_connection
  @database_connection
end

Instance Method Details

#rake_task(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pact_broker/tasks/data_migration_task.rb', line 24

def rake_task &block
  namespace :pact_broker do
    namespace :db do
      desc "Run data migrations for pact broker database"
      task :migrate_data do | _t, _args |
        require "pact_broker/db"
        instance_eval(&block)
        PactBroker::DB.run_data_migrations database_connection
      end
    end
  end
end