File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
ruby_event_store-active_record/lib/ruby_event_store/active_record/tasks Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -33,21 +33,29 @@ task "db:migrations:add_foreign_key_on_event_id" do
3333end
3434
3535class MigrationTask
36- def initialize ( task )
36+ def initialize (
37+ task ,
38+ database_url : ENV [ "DATABASE_URL" ] ,
39+ data_type : ENV [ "DATA_TYPE" ] ,
40+ migration_path : ENV [ "MIGRATION_PATH" ]
41+ )
3742 @task = task
43+ @data_type = data_type
44+ @migration_path = migration_path
45+ @database_url = database_url
3846 end
3947
4048 def establish_connection
41- ::ActiveRecord ::Base . establish_connection ( ENV [ "DATABASE_URL" ] )
49+ ::ActiveRecord ::Base . establish_connection ( @database_url )
4250 end
4351
4452 def adapter
45- data_type = ENV [ "DATA_TYPE" ] || raise ( "Specify data type (binary, json, jsonb): rake #{ @task } DATA_TYPE=json" )
53+ data_type = @data_type || raise ( "Specify data type (binary, json, jsonb): rake #{ @task } DATA_TYPE=json" )
4654
4755 RubyEventStore ::ActiveRecord ::DatabaseAdapter . from_string ( ::ActiveRecord ::Base . connection . adapter_name , data_type )
4856 end
4957
5058 def migration_path
51- ENV [ "MIGRATION_PATH" ] || "db/migrate"
59+ @migration_path || "db/migrate"
5260 end
5361end
You can’t perform that action at this time.
0 commit comments