-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose the data migrations code as a rake task
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require 'pact_broker/tasks/migration_task' | ||
require 'pact_broker/tasks/data_migration_task' | ||
require 'pact_broker/tasks/version_task' | ||
require 'pact_broker/tasks/clean_task' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'rake/tasklib' | ||
|
||
=begin | ||
require 'pact_broker/tasks' | ||
PactBroker::DB::DataMigrationTask.new do | task | | ||
require 'my_app/db' | ||
task.database_connection = MyApp::DB | ||
end | ||
=end | ||
|
||
module PactBroker | ||
module DB | ||
class DataMigrationTask < ::Rake::TaskLib | ||
|
||
attr_accessor :database_connection | ||
|
||
def initialize &block | ||
rake_task &block | ||
end | ||
|
||
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 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters