nonschema_migrations 6.5.1 → 6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +28 -0
- data/.gitignore +3 -0
- data/Appraisals +9 -26
- data/CONTRIBUTING.md +11 -0
- data/Gemfile.lock +194 -38
- data/Procfile +2 -0
- data/README.md +28 -24
- data/Rakefile +6 -4
- data/gemfiles/{rails_5_1.gemfile → rails_7_1.gemfile} +6 -5
- data/gemfiles/rails_7_1.gemfile.lock +266 -0
- data/lib/active_record/data_migration.rb +16 -1
- data/lib/active_record/data_tasks.rb +91 -0
- data/lib/nonschema_migrations/version.rb +1 -1
- data/lib/nonschema_migrator.rb +199 -167
- data/lib/tasks/data.rb +1 -7
- data/release-tasks.sh +9 -0
- metadata +16 -22
- data/gemfiles/rails_4_0.gemfile +0 -22
- data/gemfiles/rails_4_0.gemfile.lock +0 -0
- data/gemfiles/rails_4_1.gemfile +0 -21
- data/gemfiles/rails_4_1.gemfile.lock +0 -164
- data/gemfiles/rails_4_2.gemfile +0 -21
- data/gemfiles/rails_4_2.gemfile.lock +0 -189
- data/gemfiles/rails_5_0.gemfile +0 -21
- data/gemfiles/rails_5_0.gemfile.lock +0 -196
- data/gemfiles/rails_5_1.gemfile.lock +0 -195
- data/gemfiles/rails_5_2.gemfile +0 -20
- data/gemfiles/rails_5_2.gemfile.lock +0 -203
- data/gemfiles/rails_6_0.gemfile +0 -20
@@ -0,0 +1,266 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
nonschema_migrations (6.6)
|
5
|
+
rails (~> 7.1, >= 7.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (7.1.0)
|
11
|
+
actionpack (= 7.1.0)
|
12
|
+
activesupport (= 7.1.0)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
zeitwerk (~> 2.6)
|
16
|
+
actionmailbox (7.1.0)
|
17
|
+
actionpack (= 7.1.0)
|
18
|
+
activejob (= 7.1.0)
|
19
|
+
activerecord (= 7.1.0)
|
20
|
+
activestorage (= 7.1.0)
|
21
|
+
activesupport (= 7.1.0)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
net-imap
|
24
|
+
net-pop
|
25
|
+
net-smtp
|
26
|
+
actionmailer (7.1.0)
|
27
|
+
actionpack (= 7.1.0)
|
28
|
+
actionview (= 7.1.0)
|
29
|
+
activejob (= 7.1.0)
|
30
|
+
activesupport (= 7.1.0)
|
31
|
+
mail (~> 2.5, >= 2.5.4)
|
32
|
+
net-imap
|
33
|
+
net-pop
|
34
|
+
net-smtp
|
35
|
+
rails-dom-testing (~> 2.2)
|
36
|
+
actionpack (7.1.0)
|
37
|
+
actionview (= 7.1.0)
|
38
|
+
activesupport (= 7.1.0)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
rack (>= 2.2.4)
|
41
|
+
rack-session (>= 1.0.1)
|
42
|
+
rack-test (>= 0.6.3)
|
43
|
+
rails-dom-testing (~> 2.2)
|
44
|
+
rails-html-sanitizer (~> 1.6)
|
45
|
+
actiontext (7.1.0)
|
46
|
+
actionpack (= 7.1.0)
|
47
|
+
activerecord (= 7.1.0)
|
48
|
+
activestorage (= 7.1.0)
|
49
|
+
activesupport (= 7.1.0)
|
50
|
+
globalid (>= 0.6.0)
|
51
|
+
nokogiri (>= 1.8.5)
|
52
|
+
actionview (7.1.0)
|
53
|
+
activesupport (= 7.1.0)
|
54
|
+
builder (~> 3.1)
|
55
|
+
erubi (~> 1.11)
|
56
|
+
rails-dom-testing (~> 2.2)
|
57
|
+
rails-html-sanitizer (~> 1.6)
|
58
|
+
activejob (7.1.0)
|
59
|
+
activesupport (= 7.1.0)
|
60
|
+
globalid (>= 0.3.6)
|
61
|
+
activemodel (7.1.0)
|
62
|
+
activesupport (= 7.1.0)
|
63
|
+
activerecord (7.1.0)
|
64
|
+
activemodel (= 7.1.0)
|
65
|
+
activesupport (= 7.1.0)
|
66
|
+
timeout (>= 0.4.0)
|
67
|
+
activestorage (7.1.0)
|
68
|
+
actionpack (= 7.1.0)
|
69
|
+
activejob (= 7.1.0)
|
70
|
+
activerecord (= 7.1.0)
|
71
|
+
activesupport (= 7.1.0)
|
72
|
+
marcel (~> 1.0)
|
73
|
+
activesupport (7.1.0)
|
74
|
+
base64
|
75
|
+
bigdecimal
|
76
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
77
|
+
connection_pool (>= 2.2.5)
|
78
|
+
drb
|
79
|
+
i18n (>= 1.6, < 2)
|
80
|
+
minitest (>= 5.1)
|
81
|
+
mutex_m
|
82
|
+
tzinfo (~> 2.0)
|
83
|
+
appraisal (2.5.0)
|
84
|
+
bundler
|
85
|
+
rake
|
86
|
+
thor (>= 0.14.0)
|
87
|
+
base64 (0.2.0)
|
88
|
+
bigdecimal (3.1.5)
|
89
|
+
builder (3.2.4)
|
90
|
+
byebug (11.1.3)
|
91
|
+
coderay (1.1.3)
|
92
|
+
concurrent-ruby (1.2.2)
|
93
|
+
connection_pool (2.4.1)
|
94
|
+
crass (1.0.6)
|
95
|
+
date (3.3.4)
|
96
|
+
diff-lcs (1.5.0)
|
97
|
+
docile (1.4.0)
|
98
|
+
drb (2.2.0)
|
99
|
+
ruby2_keywords
|
100
|
+
erubi (1.12.0)
|
101
|
+
ffi (1.16.3)
|
102
|
+
formatador (1.1.0)
|
103
|
+
globalid (1.2.1)
|
104
|
+
activesupport (>= 6.1)
|
105
|
+
guard (2.18.1)
|
106
|
+
formatador (>= 0.2.4)
|
107
|
+
listen (>= 2.7, < 4.0)
|
108
|
+
lumberjack (>= 1.0.12, < 2.0)
|
109
|
+
nenv (~> 0.1)
|
110
|
+
notiffany (~> 0.0)
|
111
|
+
pry (>= 0.13.0)
|
112
|
+
shellany (~> 0.0)
|
113
|
+
thor (>= 0.18.1)
|
114
|
+
guard-compat (1.2.1)
|
115
|
+
guard-rspec (4.7.3)
|
116
|
+
guard (~> 2.1)
|
117
|
+
guard-compat (~> 1.1)
|
118
|
+
rspec (>= 2.99.0, < 4.0)
|
119
|
+
i18n (1.14.1)
|
120
|
+
concurrent-ruby (~> 1.0)
|
121
|
+
io-console (0.7.1)
|
122
|
+
irb (1.11.1)
|
123
|
+
rdoc
|
124
|
+
reline (>= 0.4.2)
|
125
|
+
listen (3.8.0)
|
126
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
127
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
128
|
+
loofah (2.22.0)
|
129
|
+
crass (~> 1.0.2)
|
130
|
+
nokogiri (>= 1.12.0)
|
131
|
+
lumberjack (1.2.10)
|
132
|
+
mail (2.8.1)
|
133
|
+
mini_mime (>= 0.1.1)
|
134
|
+
net-imap
|
135
|
+
net-pop
|
136
|
+
net-smtp
|
137
|
+
marcel (1.0.2)
|
138
|
+
method_source (1.0.0)
|
139
|
+
mini_mime (1.1.5)
|
140
|
+
mini_portile2 (2.8.5)
|
141
|
+
minitest (5.20.0)
|
142
|
+
minitest-rg (5.3.0)
|
143
|
+
minitest (~> 5.0)
|
144
|
+
mocha (2.1.0)
|
145
|
+
ruby2_keywords (>= 0.0.5)
|
146
|
+
mutex_m (0.2.0)
|
147
|
+
nenv (0.3.0)
|
148
|
+
net-imap (0.4.9.1)
|
149
|
+
date
|
150
|
+
net-protocol
|
151
|
+
net-pop (0.1.2)
|
152
|
+
net-protocol
|
153
|
+
net-protocol (0.2.2)
|
154
|
+
timeout
|
155
|
+
net-smtp (0.4.0.1)
|
156
|
+
net-protocol
|
157
|
+
nio4r (2.7.0)
|
158
|
+
nokogiri (1.15.5)
|
159
|
+
mini_portile2 (~> 2.8.2)
|
160
|
+
racc (~> 1.4)
|
161
|
+
notiffany (0.1.3)
|
162
|
+
nenv (~> 0.1)
|
163
|
+
shellany (~> 0.0)
|
164
|
+
pry (0.14.2)
|
165
|
+
coderay (~> 1.1)
|
166
|
+
method_source (~> 1.0)
|
167
|
+
psych (5.1.2)
|
168
|
+
stringio
|
169
|
+
racc (1.7.3)
|
170
|
+
rack (3.0.8)
|
171
|
+
rack-session (2.0.0)
|
172
|
+
rack (>= 3.0.0)
|
173
|
+
rack-test (2.1.0)
|
174
|
+
rack (>= 1.3)
|
175
|
+
rackup (2.1.0)
|
176
|
+
rack (>= 3)
|
177
|
+
webrick (~> 1.8)
|
178
|
+
rails (7.1.0)
|
179
|
+
actioncable (= 7.1.0)
|
180
|
+
actionmailbox (= 7.1.0)
|
181
|
+
actionmailer (= 7.1.0)
|
182
|
+
actionpack (= 7.1.0)
|
183
|
+
actiontext (= 7.1.0)
|
184
|
+
actionview (= 7.1.0)
|
185
|
+
activejob (= 7.1.0)
|
186
|
+
activemodel (= 7.1.0)
|
187
|
+
activerecord (= 7.1.0)
|
188
|
+
activestorage (= 7.1.0)
|
189
|
+
activesupport (= 7.1.0)
|
190
|
+
bundler (>= 1.15.0)
|
191
|
+
railties (= 7.1.0)
|
192
|
+
rails-dom-testing (2.2.0)
|
193
|
+
activesupport (>= 5.0.0)
|
194
|
+
minitest
|
195
|
+
nokogiri (>= 1.6)
|
196
|
+
rails-html-sanitizer (1.6.0)
|
197
|
+
loofah (~> 2.21)
|
198
|
+
nokogiri (~> 1.14)
|
199
|
+
railties (7.1.0)
|
200
|
+
actionpack (= 7.1.0)
|
201
|
+
activesupport (= 7.1.0)
|
202
|
+
irb
|
203
|
+
rackup (>= 1.0.0)
|
204
|
+
rake (>= 12.2)
|
205
|
+
thor (~> 1.0, >= 1.2.2)
|
206
|
+
zeitwerk (~> 2.6)
|
207
|
+
rake (13.1.0)
|
208
|
+
rb-fsevent (0.11.2)
|
209
|
+
rb-inotify (0.10.1)
|
210
|
+
ffi (~> 1.0)
|
211
|
+
rdoc (6.6.2)
|
212
|
+
psych (>= 4.0.0)
|
213
|
+
reline (0.4.2)
|
214
|
+
io-console (~> 0.5)
|
215
|
+
rspec (3.12.0)
|
216
|
+
rspec-core (~> 3.12.0)
|
217
|
+
rspec-expectations (~> 3.12.0)
|
218
|
+
rspec-mocks (~> 3.12.0)
|
219
|
+
rspec-core (3.12.2)
|
220
|
+
rspec-support (~> 3.12.0)
|
221
|
+
rspec-expectations (3.12.3)
|
222
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
223
|
+
rspec-support (~> 3.12.0)
|
224
|
+
rspec-mocks (3.12.6)
|
225
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
226
|
+
rspec-support (~> 3.12.0)
|
227
|
+
rspec-support (3.12.1)
|
228
|
+
ruby2_keywords (0.0.5)
|
229
|
+
shellany (0.0.1)
|
230
|
+
simplecov (0.22.0)
|
231
|
+
docile (~> 1.1)
|
232
|
+
simplecov-html (~> 0.11)
|
233
|
+
simplecov_json_formatter (~> 0.1)
|
234
|
+
simplecov-html (0.12.3)
|
235
|
+
simplecov_json_formatter (0.1.4)
|
236
|
+
sqlite3 (1.7.0)
|
237
|
+
mini_portile2 (~> 2.8.0)
|
238
|
+
stringio (3.1.0)
|
239
|
+
thor (1.3.0)
|
240
|
+
timeout (0.4.1)
|
241
|
+
tzinfo (2.0.6)
|
242
|
+
concurrent-ruby (~> 1.0)
|
243
|
+
webrick (1.8.1)
|
244
|
+
websocket-driver (0.7.6)
|
245
|
+
websocket-extensions (>= 0.1.0)
|
246
|
+
websocket-extensions (0.1.5)
|
247
|
+
zeitwerk (2.6.12)
|
248
|
+
|
249
|
+
PLATFORMS
|
250
|
+
ruby
|
251
|
+
|
252
|
+
DEPENDENCIES
|
253
|
+
appraisal
|
254
|
+
byebug
|
255
|
+
guard
|
256
|
+
guard-rspec
|
257
|
+
minitest-rg
|
258
|
+
mocha
|
259
|
+
nonschema_migrations!
|
260
|
+
rails (= 7.1)
|
261
|
+
rake
|
262
|
+
simplecov
|
263
|
+
sqlite3
|
264
|
+
|
265
|
+
BUNDLED WITH
|
266
|
+
2.4.22
|
@@ -4,6 +4,21 @@ require 'active_record/base'
|
|
4
4
|
|
5
5
|
module ActiveRecord
|
6
6
|
class DataMigration < ActiveRecord::Base
|
7
|
+
def initialize(migrations)
|
8
|
+
|
9
|
+
@migration_struct = migrations
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def up
|
14
|
+
Migrator.new(:up, @migration_struct).migrate
|
15
|
+
end
|
16
|
+
|
17
|
+
def down
|
18
|
+
Migrator.new(:down, @migration_struct).migrate
|
19
|
+
end
|
20
|
+
|
21
|
+
|
7
22
|
class << self
|
8
23
|
def primary_key
|
9
24
|
nil
|
@@ -49,4 +64,4 @@ module ActiveRecord
|
|
49
64
|
super.to_i
|
50
65
|
end
|
51
66
|
end
|
52
|
-
end
|
67
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "active_record/database_configurations"
|
5
|
+
|
6
|
+
module ActiveRecord
|
7
|
+
module Tasks # :nodoc:
|
8
|
+
class DatabaseNotSupported < StandardError; end # :nodoc:
|
9
|
+
|
10
|
+
|
11
|
+
module DataTasks
|
12
|
+
##
|
13
|
+
# :singleton-method:
|
14
|
+
# Extra flags passed to database CLI tool (mysqldump/pg_dump) when calling db:schema:dump
|
15
|
+
# It can be used as a string/array (the typical case) or a hash (when you use multiple adapters)
|
16
|
+
# Example:
|
17
|
+
# ActiveRecord::Tasks::DatabaseTasks.structure_dump_flags = {
|
18
|
+
# mysql2: ['--no-defaults', '--skip-add-drop-table'],
|
19
|
+
# postgres: '--no-tablespaces'
|
20
|
+
# }
|
21
|
+
mattr_accessor :structure_dump_flags, instance_accessor: false
|
22
|
+
|
23
|
+
##
|
24
|
+
# :singleton-method:
|
25
|
+
# Extra flags passed to database CLI tool when calling db:schema:load
|
26
|
+
# It can be used as a string/array (the typical case) or a hash (when you use multiple adapters)
|
27
|
+
mattr_accessor :structure_load_flags, instance_accessor: false
|
28
|
+
|
29
|
+
extend self
|
30
|
+
|
31
|
+
attr_writer :data_dir, :migrations_paths, :fixtures_path, :root, :env, :seed_loader
|
32
|
+
attr_accessor :database_configuration
|
33
|
+
|
34
|
+
|
35
|
+
def self.data_migrations_table_name
|
36
|
+
"data_migrations"
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_protected_environments!(environment = env)
|
40
|
+
return if ENV["DISABLE_DATABASE_ENVIRONMENT_CHECK"]
|
41
|
+
|
42
|
+
configs_for(env_name: environment).each do |db_config|
|
43
|
+
check_current_protected_environment!(db_config)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def data_dir
|
48
|
+
@data_dir ||= Rails.application.config.paths["data"].first
|
49
|
+
end
|
50
|
+
|
51
|
+
def migrations_paths
|
52
|
+
@migrations_paths ||= Rails.application.paths["data/migrate"].to_a
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_migration_filename(filename)
|
56
|
+
File.basename(filename).scan(Migration::MigrationFilenameRegexp).first
|
57
|
+
end
|
58
|
+
|
59
|
+
def migration_files
|
60
|
+
paths = Array(Rails.root.join('db', 'data_migrate'))
|
61
|
+
Dir[*paths.flat_map { |path| "#{path}/**/[0-9]*_*.rb" }]
|
62
|
+
end
|
63
|
+
|
64
|
+
def migrate(version = nil)
|
65
|
+
# get all data migrations in data/migrations
|
66
|
+
# get list of data migrations in database
|
67
|
+
already_done = ActiveRecord::Base.connection.execute("SELECT version FROM data_migrations").map { |record| record['version'].to_i }
|
68
|
+
|
69
|
+
data_migrations = migration_files.map do |file|
|
70
|
+
version, name, scope = parse_migration_filename(file)
|
71
|
+
raise IllegalMigrationNameError.new(file) unless version
|
72
|
+
version = version.to_i
|
73
|
+
name = name.camelize
|
74
|
+
|
75
|
+
MigrationProxy.new(name, version, file, scope)
|
76
|
+
end
|
77
|
+
data_migrations.reject! do |mig|
|
78
|
+
already_done.include?(mig.version)
|
79
|
+
end
|
80
|
+
data_migrations.each do |migration|
|
81
|
+
require migration.filename
|
82
|
+
(eval(migration.name).new).migrate(:up)
|
83
|
+
|
84
|
+
# push the migration into the database
|
85
|
+
ActiveRecord::Base.connection.execute("INSERT INTO data_migrations (version) VALUES (#{migration.version})")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|