File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ module DB
16
16
class MigrationTask < ::Rake ::TaskLib
17
17
18
18
attr_accessor :database_connection
19
+ attr_accessor :options
19
20
20
21
def initialize &block
22
+ @options = { }
21
23
rake_task &block
22
24
end
23
25
@@ -27,12 +29,29 @@ def rake_task &block
27
29
desc "Run sequel migrations for pact broker database"
28
30
task :migrate , [ :target ] do | t , args |
29
31
require 'pact_broker/db/migrate'
32
+ require 'pact_broker/db/version'
33
+
30
34
instance_eval ( &block )
31
- options = { }
35
+
32
36
if args [ :target ]
33
37
options [ :target ] = args [ :target ] . to_i
34
38
end
39
+
40
+ if ( logger = database_connection . loggers . first )
41
+ current_version = PactBroker ::DB ::Version . call ( database_connection )
42
+ if options [ :target ]
43
+ logger . info "Migrating from schema version #{ current_version } to #{ options [ :target ] } "
44
+ else
45
+ logger . info "Migrating from schema version #{ current_version } to latest"
46
+ end
47
+ end
48
+
35
49
PactBroker ::DB ::Migrate . call ( database_connection , options )
50
+
51
+ if logger
52
+ current_version = PactBroker ::DB ::Version . call ( database_connection )
53
+ logger . info "Current schema version is now #{ current_version } "
54
+ end
36
55
end
37
56
end
38
57
end
You can’t perform that action at this time.
0 commit comments