data_migrate 9.2.0 → 9.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,74 +1,74 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.2.0)
4
+ data_migrate (9.3.0)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.6)
12
- actionpack (= 7.0.6)
13
- activesupport (= 7.0.6)
11
+ actioncable (7.0.8.1)
12
+ actionpack (= 7.0.8.1)
13
+ activesupport (= 7.0.8.1)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.6)
17
- actionpack (= 7.0.6)
18
- activejob (= 7.0.6)
19
- activerecord (= 7.0.6)
20
- activestorage (= 7.0.6)
21
- activesupport (= 7.0.6)
16
+ actionmailbox (7.0.8.1)
17
+ actionpack (= 7.0.8.1)
18
+ activejob (= 7.0.8.1)
19
+ activerecord (= 7.0.8.1)
20
+ activestorage (= 7.0.8.1)
21
+ activesupport (= 7.0.8.1)
22
22
  mail (>= 2.7.1)
23
23
  net-imap
24
24
  net-pop
25
25
  net-smtp
26
- actionmailer (7.0.6)
27
- actionpack (= 7.0.6)
28
- actionview (= 7.0.6)
29
- activejob (= 7.0.6)
30
- activesupport (= 7.0.6)
26
+ actionmailer (7.0.8.1)
27
+ actionpack (= 7.0.8.1)
28
+ actionview (= 7.0.8.1)
29
+ activejob (= 7.0.8.1)
30
+ activesupport (= 7.0.8.1)
31
31
  mail (~> 2.5, >= 2.5.4)
32
32
  net-imap
33
33
  net-pop
34
34
  net-smtp
35
35
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.6)
37
- actionview (= 7.0.6)
38
- activesupport (= 7.0.6)
36
+ actionpack (7.0.8.1)
37
+ actionview (= 7.0.8.1)
38
+ activesupport (= 7.0.8.1)
39
39
  rack (~> 2.0, >= 2.2.4)
40
40
  rack-test (>= 0.6.3)
41
41
  rails-dom-testing (~> 2.0)
42
42
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.6)
44
- actionpack (= 7.0.6)
45
- activerecord (= 7.0.6)
46
- activestorage (= 7.0.6)
47
- activesupport (= 7.0.6)
43
+ actiontext (7.0.8.1)
44
+ actionpack (= 7.0.8.1)
45
+ activerecord (= 7.0.8.1)
46
+ activestorage (= 7.0.8.1)
47
+ activesupport (= 7.0.8.1)
48
48
  globalid (>= 0.6.0)
49
49
  nokogiri (>= 1.8.5)
50
- actionview (7.0.6)
51
- activesupport (= 7.0.6)
50
+ actionview (7.0.8.1)
51
+ activesupport (= 7.0.8.1)
52
52
  builder (~> 3.1)
53
53
  erubi (~> 1.4)
54
54
  rails-dom-testing (~> 2.0)
55
55
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.6)
57
- activesupport (= 7.0.6)
56
+ activejob (7.0.8.1)
57
+ activesupport (= 7.0.8.1)
58
58
  globalid (>= 0.3.6)
59
- activemodel (7.0.6)
60
- activesupport (= 7.0.6)
61
- activerecord (7.0.6)
62
- activemodel (= 7.0.6)
63
- activesupport (= 7.0.6)
64
- activestorage (7.0.6)
65
- actionpack (= 7.0.6)
66
- activejob (= 7.0.6)
67
- activerecord (= 7.0.6)
68
- activesupport (= 7.0.6)
59
+ activemodel (7.0.8.1)
60
+ activesupport (= 7.0.8.1)
61
+ activerecord (7.0.8.1)
62
+ activemodel (= 7.0.8.1)
63
+ activesupport (= 7.0.8.1)
64
+ activestorage (7.0.8.1)
65
+ actionpack (= 7.0.8.1)
66
+ activejob (= 7.0.8.1)
67
+ activerecord (= 7.0.8.1)
68
+ activesupport (= 7.0.8.1)
69
69
  marcel (~> 1.0)
70
70
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.6)
71
+ activesupport (7.0.8.1)
72
72
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
73
  i18n (>= 1.6, < 2)
74
74
  minitest (>= 5.1)
@@ -81,19 +81,19 @@ GEM
81
81
  builder (3.2.4)
82
82
  childprocess (4.1.0)
83
83
  coderay (1.1.3)
84
- concurrent-ruby (1.2.2)
84
+ concurrent-ruby (1.2.3)
85
85
  crass (1.0.6)
86
- date (3.3.3)
86
+ date (3.3.4)
87
87
  diff-lcs (1.5.0)
88
88
  erubi (1.12.0)
89
- globalid (1.1.0)
90
- activesupport (>= 5.0)
89
+ globalid (1.2.1)
90
+ activesupport (>= 6.1)
91
91
  i18n (1.14.1)
92
92
  concurrent-ruby (~> 1.0)
93
93
  iniparse (1.5.0)
94
94
  json (2.6.3)
95
95
  language_server-protocol (3.17.0.3)
96
- loofah (2.21.3)
96
+ loofah (2.22.0)
97
97
  crass (~> 1.0.2)
98
98
  nokogiri (>= 1.12.0)
99
99
  mail (2.8.1)
@@ -103,21 +103,21 @@ GEM
103
103
  net-smtp
104
104
  marcel (1.0.2)
105
105
  method_source (1.0.0)
106
- mini_mime (1.1.2)
107
- minitest (5.18.1)
108
- net-imap (0.3.6)
106
+ mini_mime (1.1.5)
107
+ minitest (5.22.2)
108
+ net-imap (0.4.10)
109
109
  date
110
110
  net-protocol
111
111
  net-pop (0.1.2)
112
112
  net-protocol
113
- net-protocol (0.2.1)
113
+ net-protocol (0.2.2)
114
114
  timeout
115
- net-smtp (0.3.3)
115
+ net-smtp (0.4.0.1)
116
116
  net-protocol
117
- nio4r (2.5.9)
118
- nokogiri (1.15.3-arm64-darwin)
117
+ nio4r (2.7.0)
118
+ nokogiri (1.16.2-arm64-darwin)
119
119
  racc (~> 1.4)
120
- nokogiri (1.15.3-x86_64-linux)
120
+ nokogiri (1.16.2-x86_64-linux)
121
121
  racc (~> 1.4)
122
122
  overcommit (0.60.0)
123
123
  childprocess (>= 0.6.3, < 5)
@@ -130,40 +130,40 @@ GEM
130
130
  pry (0.14.2)
131
131
  coderay (~> 1.1)
132
132
  method_source (~> 1.0)
133
- racc (1.7.1)
134
- rack (2.2.7)
133
+ racc (1.7.3)
134
+ rack (2.2.8.1)
135
135
  rack-test (2.1.0)
136
136
  rack (>= 1.3)
137
- rails (7.0.6)
138
- actioncable (= 7.0.6)
139
- actionmailbox (= 7.0.6)
140
- actionmailer (= 7.0.6)
141
- actionpack (= 7.0.6)
142
- actiontext (= 7.0.6)
143
- actionview (= 7.0.6)
144
- activejob (= 7.0.6)
145
- activemodel (= 7.0.6)
146
- activerecord (= 7.0.6)
147
- activestorage (= 7.0.6)
148
- activesupport (= 7.0.6)
137
+ rails (7.0.8.1)
138
+ actioncable (= 7.0.8.1)
139
+ actionmailbox (= 7.0.8.1)
140
+ actionmailer (= 7.0.8.1)
141
+ actionpack (= 7.0.8.1)
142
+ actiontext (= 7.0.8.1)
143
+ actionview (= 7.0.8.1)
144
+ activejob (= 7.0.8.1)
145
+ activemodel (= 7.0.8.1)
146
+ activerecord (= 7.0.8.1)
147
+ activestorage (= 7.0.8.1)
148
+ activesupport (= 7.0.8.1)
149
149
  bundler (>= 1.15.0)
150
- railties (= 7.0.6)
151
- rails-dom-testing (2.1.1)
150
+ railties (= 7.0.8.1)
151
+ rails-dom-testing (2.2.0)
152
152
  activesupport (>= 5.0.0)
153
153
  minitest
154
154
  nokogiri (>= 1.6)
155
155
  rails-html-sanitizer (1.6.0)
156
156
  loofah (~> 2.21)
157
157
  nokogiri (~> 1.14)
158
- railties (7.0.6)
159
- actionpack (= 7.0.6)
160
- activesupport (= 7.0.6)
158
+ railties (7.0.8.1)
159
+ actionpack (= 7.0.8.1)
160
+ activesupport (= 7.0.8.1)
161
161
  method_source
162
162
  rake (>= 12.2)
163
163
  thor (~> 1.0)
164
164
  zeitwerk (~> 2.5)
165
165
  rainbow (3.1.1)
166
- rake (13.0.6)
166
+ rake (13.1.0)
167
167
  rb-readline (0.5.5)
168
168
  regexp_parser (2.8.1)
169
169
  rexml (3.2.5)
@@ -194,21 +194,22 @@ GEM
194
194
  rubocop-ast (1.29.0)
195
195
  parser (>= 3.2.1.0)
196
196
  ruby-progressbar (1.13.0)
197
- sqlite3 (1.6.3-arm64-darwin)
198
- sqlite3 (1.6.3-x86_64-linux)
199
- thor (1.2.2)
197
+ sqlite3 (1.7.2-arm64-darwin)
198
+ sqlite3 (1.7.2-x86_64-linux)
199
+ thor (1.3.1)
200
200
  timecop (0.9.6)
201
- timeout (0.4.0)
201
+ timeout (0.4.1)
202
202
  tzinfo (2.0.6)
203
203
  concurrent-ruby (~> 1.0)
204
204
  unicode-display_width (2.4.2)
205
- websocket-driver (0.7.5)
205
+ websocket-driver (0.7.6)
206
206
  websocket-extensions (>= 0.1.0)
207
207
  websocket-extensions (0.1.5)
208
- zeitwerk (2.6.8)
208
+ zeitwerk (2.6.13)
209
209
 
210
210
  PLATFORMS
211
211
  arm64-darwin-22
212
+ arm64-darwin-23
212
213
  x86_64-linux
213
214
 
214
215
  DEPENDENCIES
@@ -216,14 +217,14 @@ DEPENDENCIES
216
217
  data_migrate!
217
218
  overcommit
218
219
  pry
219
- rails (~> 7.0)
220
+ rails (~> 7.0.0)
220
221
  rake
221
222
  rb-readline
222
223
  rspec
223
224
  rspec-core
224
225
  rubocop
225
- sqlite3 (~> 1.4)
226
+ sqlite3
226
227
  timecop
227
228
 
228
229
  BUNDLED WITH
229
- 2.4.14
230
+ 2.5.6
@@ -2,7 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "sqlite3", "~> 1.4"
6
5
  gem "rails", "7.1.0"
7
6
 
8
7
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- data_migrate (9.2.0)
4
+ data_migrate (9.3.0)
5
5
  activerecord (>= 6.1)
6
6
  railties (>= 6.1)
7
7
 
@@ -86,17 +86,17 @@ GEM
86
86
  rake
87
87
  thor (>= 0.14.0)
88
88
  ast (2.4.2)
89
- base64 (0.1.1)
90
- bigdecimal (3.1.4)
89
+ base64 (0.2.0)
90
+ bigdecimal (3.1.6)
91
91
  builder (3.2.4)
92
92
  childprocess (4.1.0)
93
93
  coderay (1.1.3)
94
- concurrent-ruby (1.2.2)
94
+ concurrent-ruby (1.2.3)
95
95
  connection_pool (2.4.1)
96
96
  crass (1.0.6)
97
- date (3.3.3)
97
+ date (3.3.4)
98
98
  diff-lcs (1.5.0)
99
- drb (2.1.1)
99
+ drb (2.2.0)
100
100
  ruby2_keywords
101
101
  erubi (1.12.0)
102
102
  globalid (1.2.1)
@@ -104,13 +104,13 @@ GEM
104
104
  i18n (1.14.1)
105
105
  concurrent-ruby (~> 1.0)
106
106
  iniparse (1.5.0)
107
- io-console (0.6.0)
108
- irb (1.8.1)
107
+ io-console (0.7.2)
108
+ irb (1.11.2)
109
109
  rdoc
110
- reline (>= 0.3.8)
110
+ reline (>= 0.4.2)
111
111
  json (2.6.3)
112
112
  language_server-protocol (3.17.0.3)
113
- loofah (2.21.3)
113
+ loofah (2.22.0)
114
114
  crass (~> 1.0.2)
115
115
  nokogiri (>= 1.12.0)
116
116
  mail (2.8.1)
@@ -118,24 +118,24 @@ GEM
118
118
  net-imap
119
119
  net-pop
120
120
  net-smtp
121
- marcel (1.0.2)
121
+ marcel (1.0.4)
122
122
  method_source (1.0.0)
123
123
  mini_mime (1.1.5)
124
- minitest (5.20.0)
125
- mutex_m (0.1.2)
126
- net-imap (0.4.0)
124
+ minitest (5.22.2)
125
+ mutex_m (0.2.0)
126
+ net-imap (0.4.10)
127
127
  date
128
128
  net-protocol
129
129
  net-pop (0.1.2)
130
130
  net-protocol
131
- net-protocol (0.2.1)
131
+ net-protocol (0.2.2)
132
132
  timeout
133
- net-smtp (0.4.0)
133
+ net-smtp (0.4.0.1)
134
134
  net-protocol
135
- nio4r (2.5.9)
136
- nokogiri (1.15.4-arm64-darwin)
135
+ nio4r (2.7.0)
136
+ nokogiri (1.16.2-arm64-darwin)
137
137
  racc (~> 1.4)
138
- nokogiri (1.15.4-x86_64-linux)
138
+ nokogiri (1.16.2-x86_64-linux)
139
139
  racc (~> 1.4)
140
140
  overcommit (0.60.0)
141
141
  childprocess (>= 0.6.3, < 5)
@@ -148,10 +148,10 @@ GEM
148
148
  pry (0.14.2)
149
149
  coderay (~> 1.1)
150
150
  method_source (~> 1.0)
151
- psych (5.1.0)
151
+ psych (5.1.2)
152
152
  stringio
153
- racc (1.7.1)
154
- rack (3.0.8)
153
+ racc (1.7.3)
154
+ rack (3.0.9.1)
155
155
  rack-session (2.0.0)
156
156
  rack (>= 3.0.0)
157
157
  rack-test (2.1.0)
@@ -189,12 +189,12 @@ GEM
189
189
  thor (~> 1.0, >= 1.2.2)
190
190
  zeitwerk (~> 2.6)
191
191
  rainbow (3.1.1)
192
- rake (13.0.6)
192
+ rake (13.1.0)
193
193
  rb-readline (0.5.5)
194
- rdoc (6.5.0)
194
+ rdoc (6.6.2)
195
195
  psych (>= 4.0.0)
196
196
  regexp_parser (2.8.1)
197
- reline (0.3.9)
197
+ reline (0.4.3)
198
198
  io-console (~> 0.5)
199
199
  rexml (3.2.5)
200
200
  rspec (3.12.0)
@@ -225,12 +225,12 @@ GEM
225
225
  parser (>= 3.2.1.0)
226
226
  ruby-progressbar (1.13.0)
227
227
  ruby2_keywords (0.0.5)
228
- sqlite3 (1.6.3-arm64-darwin)
229
- sqlite3 (1.6.3-x86_64-linux)
230
- stringio (3.0.8)
231
- thor (1.2.2)
228
+ sqlite3 (1.7.2-arm64-darwin)
229
+ sqlite3 (1.7.2-x86_64-linux)
230
+ stringio (3.1.0)
231
+ thor (1.3.1)
232
232
  timecop (0.9.6)
233
- timeout (0.4.0)
233
+ timeout (0.4.1)
234
234
  tzinfo (2.0.6)
235
235
  concurrent-ruby (~> 1.0)
236
236
  unicode-display_width (2.4.2)
@@ -238,10 +238,11 @@ GEM
238
238
  websocket-driver (0.7.6)
239
239
  websocket-extensions (>= 0.1.0)
240
240
  websocket-extensions (0.1.5)
241
- zeitwerk (2.6.12)
241
+ zeitwerk (2.6.13)
242
242
 
243
243
  PLATFORMS
244
244
  arm64-darwin-22
245
+ arm64-darwin-23
245
246
  x86_64-linux
246
247
 
247
248
  DEPENDENCIES
@@ -255,7 +256,7 @@ DEPENDENCIES
255
256
  rspec
256
257
  rspec-core
257
258
  rubocop
258
- sqlite3 (~> 1.4)
259
+ sqlite3
259
260
  timecop
260
261
 
261
262
  BUNDLED WITH
@@ -0,0 +1,11 @@
1
+ module DataMigrate
2
+ # This wrapper is used to differentiate between
3
+ # a data and schema db config when running migrations
4
+ class DatabaseConfigurationWrapper
5
+ attr_reader :db_config
6
+
7
+ def initialize(db_config)
8
+ @db_config = db_config
9
+ end
10
+ end
11
+ end
@@ -5,87 +5,142 @@ require "data_migrate/config"
5
5
  module DataMigrate
6
6
  ##
7
7
  # This class extends DatabaseTasks to add a schema_file method.
8
- class DatabaseTasks
8
+ module DatabaseTasks
9
9
  extend ActiveRecord::Tasks::DatabaseTasks
10
-
11
- class << self
12
- def schema_file(_format = nil)
13
- File.join(db_dir, "data_schema.rb")
14
- end
15
-
16
- def schema_file_type(_format = nil)
17
- "data_schema.rb"
18
- end
19
-
20
- # This method is removed in Rails 7.0
21
- def dump_filename(spec_name, format = ActiveRecord::Base.schema_format)
22
- filename = if spec_name == "primary"
23
- schema_file_type(format)
10
+ extend self
11
+
12
+ # These method are only introduced in Rails 7.1
13
+ unless respond_to?(:with_temporary_connection_for_each)
14
+ def with_temporary_connection_for_each(env: ActiveRecord::Tasks::DatabaseTasks.env, name: nil, &block) # :nodoc:
15
+ if name
16
+ db_config = ActiveRecord::Base.configurations.configs_for(env_name: env, name: name)
17
+ with_temporary_connection(db_config, &block)
24
18
  else
25
- "#{spec_name}_#{schema_file_type(format)}"
19
+ ActiveRecord::Base.configurations.configs_for(env_name: env, name: name).each do |db_config|
20
+ with_temporary_connection(db_config, &block)
21
+ end
26
22
  end
27
-
28
- ENV["DATA_SCHEMA"] || File.join(db_dir, filename)
29
23
  end
30
24
 
31
- def check_schema_file(filename)
32
- unless File.exist?(filename)
33
- message = +%{#{filename} doesn't exist yet. Run `rake data:migrate` to create it, then try again.}
34
- Kernel.abort message
25
+ def with_temporary_connection(db_config) # :nodoc:
26
+ with_temporary_pool(db_config) do |pool|
27
+ yield pool.connection
35
28
  end
36
29
  end
37
30
 
38
- def pending_migrations
39
- sort_migrations(
40
- pending_schema_migrations,
41
- pending_data_migrations
42
- )
31
+ def migration_class # :nodoc:
32
+ ActiveRecord::Base
43
33
  end
44
34
 
45
- def sort_migrations(*migrations)
46
- migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) }
35
+ def migration_connection # :nodoc:
36
+ migration_class.connection
47
37
  end
48
38
 
49
- def sort_string migration
50
- "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}"
51
- end
39
+ private def with_temporary_pool(db_config)
40
+ original_db_config = migration_class.connection_db_config
41
+ pool = migration_class.connection_handler.establish_connection(db_config)
52
42
 
53
- def data_migrations_path
54
- ::DataMigrate.config.data_migrations_path
43
+ yield pool
44
+ ensure
45
+ migration_class.connection_handler.establish_connection(original_db_config)
55
46
  end
47
+ end
56
48
 
57
- def run_migration(migration, direction)
58
- if migration[:kind] == :data
59
- ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
60
- ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version])
61
- else
62
- ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
63
- ::DataMigrate::SchemaMigration.run(
64
- direction,
65
- ::DataMigrate::SchemaMigration.migrations_paths,
66
- migration[:version]
67
- )
49
+ def db_configs_with_versions
50
+ db_configs_with_versions = Hash.new { |h, k| h[k] = [] }
51
+
52
+ with_temporary_connection_for_each do |conn|
53
+ db_config = conn.pool.db_config
54
+ if db_config.primary?
55
+ versions_to_run = DataMigrate::DatabaseTasks.pending_data_migrations.map { |m| m[:version] }
56
+ target_version = ActiveRecord::Tasks::DatabaseTasks.target_version
57
+
58
+ versions_to_run.each do |version|
59
+ next if target_version && target_version != version
60
+ db_configs_with_versions[version] << DatabaseConfigurationWrapper.new(db_config)
61
+ end
68
62
  end
69
63
  end
70
64
 
71
- def schema_dump_path(db_config, format = ActiveRecord.schema_format)
72
- return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"]
65
+ db_configs_with_versions
66
+ end
73
67
 
74
- # We only require a schema.rb file for the primary database
75
- return unless db_config.primary?
68
+ def schema_file(_format = nil)
69
+ File.join(db_dir, "data_schema.rb")
70
+ end
76
71
 
77
- File.join(File.dirname(ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config, format)), schema_file_type)
72
+ def schema_file_type(_format = nil)
73
+ "data_schema.rb"
74
+ end
75
+
76
+ # This method is removed in Rails 7.0
77
+ def dump_filename(spec_name, format = ActiveRecord::Base.schema_format)
78
+ filename = if spec_name == "primary"
79
+ schema_file_type(format)
80
+ else
81
+ "#{spec_name}_#{schema_file_type(format)}"
78
82
  end
79
83
 
80
- # Override this method from `ActiveRecord::Tasks::DatabaseTasks`
81
- # to ensure that the sha saved in ar_internal_metadata table
82
- # is from the original schema.rb file
83
- def schema_sha1(file)
84
- ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env, name: "primary"))
84
+ ENV["DATA_SCHEMA"] || File.join(db_dir, filename)
85
+ end
86
+
87
+ def check_schema_file(filename)
88
+ unless File.exist?(filename)
89
+ message = +%{#{filename} doesn't exist yet. Run `rake data:migrate` to create it, then try again.}
90
+ Kernel.abort message
85
91
  end
86
92
  end
87
93
 
88
- def self.forward(step = 1)
94
+ def pending_migrations
95
+ sort_migrations(
96
+ pending_schema_migrations,
97
+ pending_data_migrations
98
+ )
99
+ end
100
+
101
+ def sort_migrations(*migrations)
102
+ migrations.flatten.sort { |a, b| sort_string(a) <=> sort_string(b) }
103
+ end
104
+
105
+ def sort_string migration
106
+ "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}"
107
+ end
108
+
109
+ def data_migrations_path
110
+ ::DataMigrate.config.data_migrations_path
111
+ end
112
+
113
+ def run_migration(migration, direction)
114
+ if migration[:kind] == :data
115
+ ::ActiveRecord::Migration.write("== %s %s" % ['Data', "=" * 71])
116
+ ::DataMigrate::DataMigrator.run(direction, data_migrations_path, migration[:version])
117
+ else
118
+ ::ActiveRecord::Migration.write("== %s %s" % ['Schema', "=" * 69])
119
+ ::DataMigrate::SchemaMigration.run(
120
+ direction,
121
+ ::DataMigrate::SchemaMigration.migrations_paths,
122
+ migration[:version]
123
+ )
124
+ end
125
+ end
126
+
127
+ def schema_dump_path(db_config, format = ActiveRecord.schema_format)
128
+ return ENV["DATA_SCHEMA"] if ENV["DATA_SCHEMA"]
129
+
130
+ # We only require a schema.rb file for the primary database
131
+ return unless db_config.primary?
132
+
133
+ File.join(File.dirname(ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(db_config, format)), schema_file_type)
134
+ end
135
+
136
+ # Override this method from `ActiveRecord::Tasks::DatabaseTasks`
137
+ # to ensure that the sha saved in ar_internal_metadata table
138
+ # is from the original schema.rb file
139
+ def schema_sha1(file)
140
+ ActiveRecord::Tasks::DatabaseTasks.schema_dump_path(ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env, name: "primary"))
141
+ end
142
+
143
+ def forward(step = 1)
89
144
  DataMigrate::DataMigrator.create_data_schema_table
90
145
  migrations = pending_migrations.reverse.pop(step).reverse
91
146
  migrations.each do | pending_migration |
@@ -99,7 +154,7 @@ module DataMigrate
99
154
  end
100
155
  end
101
156
 
102
- def self.pending_data_migrations
157
+ def pending_data_migrations
103
158
  data_migrations = DataMigrate::DataMigrator.migrations(data_migrations_path)
104
159
  data_migrator = DataMigrate::RailsHelper.data_migrator(:up, data_migrations)
105
160
  sort_migrations(
@@ -107,11 +162,11 @@ module DataMigrate
107
162
  )
108
163
  end
109
164
 
110
- def self.pending_schema_migrations
165
+ def pending_schema_migrations
111
166
  ::DataMigrate::SchemaMigration.pending_schema_migrations
112
167
  end
113
168
 
114
- def self.past_migrations(sort = nil)
169
+ def past_migrations(sort = nil)
115
170
  data_versions = DataMigrate::RailsHelper.data_schema_migration.table_exists? ? DataMigrate::RailsHelper.data_schema_migration.normalized_versions : []
116
171
  schema_versions = DataMigrate::RailsHelper.schema_migration.normalized_versions
117
172
  migrations = data_versions.map { |v| { version: v.to_i, kind: :data } } + schema_versions.map { |v| { version: v.to_i, kind: :schema } }
@@ -0,0 +1,14 @@
1
+ module Base
2
+ extend self
3
+
4
+ def foo
5
+ puts "Base#foo called"
6
+ end
7
+ end
8
+
9
+ module Child
10
+ extend Base
11
+ extend self
12
+
13
+ puts "foo: #{respond_to?(:foo)}"
14
+ end