nandi 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +477 -0
  3. data/Rakefile +8 -0
  4. data/exe/nandi-enforce +36 -0
  5. data/lib/generators/nandi/check_constraint/USAGE +19 -0
  6. data/lib/generators/nandi/check_constraint/check_constraint_generator.rb +52 -0
  7. data/lib/generators/nandi/check_constraint/templates/add_check_constraint.rb +15 -0
  8. data/lib/generators/nandi/check_constraint/templates/validate_check_constraint.rb +9 -0
  9. data/lib/generators/nandi/compile/USAGE +19 -0
  10. data/lib/generators/nandi/compile/compile_generator.rb +62 -0
  11. data/lib/generators/nandi/foreign_key/USAGE +47 -0
  12. data/lib/generators/nandi/foreign_key/foreign_key_generator.rb +91 -0
  13. data/lib/generators/nandi/foreign_key/templates/add_foreign_key.rb +13 -0
  14. data/lib/generators/nandi/foreign_key/templates/add_reference.rb +11 -0
  15. data/lib/generators/nandi/foreign_key/templates/validate_foreign_key.rb +9 -0
  16. data/lib/generators/nandi/migration/USAGE +9 -0
  17. data/lib/generators/nandi/migration/migration_generator.rb +24 -0
  18. data/lib/generators/nandi/migration/templates/migration.rb +13 -0
  19. data/lib/generators/nandi/not_null_check/USAGE +19 -0
  20. data/lib/generators/nandi/not_null_check/not_null_check_generator.rb +56 -0
  21. data/lib/generators/nandi/not_null_check/templates/add_not_null_check.rb +11 -0
  22. data/lib/generators/nandi/not_null_check/templates/validate_not_null_check.rb +9 -0
  23. data/lib/nandi.rb +35 -0
  24. data/lib/nandi/compiled_migration.rb +86 -0
  25. data/lib/nandi/config.rb +126 -0
  26. data/lib/nandi/file_diff.rb +32 -0
  27. data/lib/nandi/file_matcher.rb +72 -0
  28. data/lib/nandi/formatting.rb +79 -0
  29. data/lib/nandi/instructions.rb +19 -0
  30. data/lib/nandi/instructions/add_check_constraint.rb +23 -0
  31. data/lib/nandi/instructions/add_column.rb +24 -0
  32. data/lib/nandi/instructions/add_foreign_key.rb +40 -0
  33. data/lib/nandi/instructions/add_index.rb +50 -0
  34. data/lib/nandi/instructions/change_column_default.rb +23 -0
  35. data/lib/nandi/instructions/create_table.rb +83 -0
  36. data/lib/nandi/instructions/drop_constraint.rb +22 -0
  37. data/lib/nandi/instructions/drop_table.rb +21 -0
  38. data/lib/nandi/instructions/irreversible_migration.rb +15 -0
  39. data/lib/nandi/instructions/remove_column.rb +23 -0
  40. data/lib/nandi/instructions/remove_index.rb +41 -0
  41. data/lib/nandi/instructions/remove_not_null_constraint.rb +22 -0
  42. data/lib/nandi/instructions/validate_constraint.rb +22 -0
  43. data/lib/nandi/lockfile.rb +58 -0
  44. data/lib/nandi/migration.rb +363 -0
  45. data/lib/nandi/renderers.rb +7 -0
  46. data/lib/nandi/renderers/active_record.rb +13 -0
  47. data/lib/nandi/renderers/active_record/generate.rb +59 -0
  48. data/lib/nandi/renderers/active_record/instructions.rb +134 -0
  49. data/lib/nandi/safe_migration_enforcer.rb +143 -0
  50. data/lib/nandi/timeout_policies.rb +38 -0
  51. data/lib/nandi/timeout_policies/access_exclusive.rb +54 -0
  52. data/lib/nandi/timeout_policies/concurrent.rb +64 -0
  53. data/lib/nandi/validation.rb +10 -0
  54. data/lib/nandi/validation/add_column_validator.rb +43 -0
  55. data/lib/nandi/validation/each_validator.rb +32 -0
  56. data/lib/nandi/validation/failure_helpers.rb +35 -0
  57. data/lib/nandi/validation/remove_index_validator.rb +30 -0
  58. data/lib/nandi/validation/result.rb +30 -0
  59. data/lib/nandi/validation/timeout_validator.rb +37 -0
  60. data/lib/nandi/validator.rb +102 -0
  61. data/lib/nandi/version.rb +5 -0
  62. data/lib/templates/nandi/renderers/active_record/generate/show.rb.erb +27 -0
  63. data/lib/templates/nandi/renderers/active_record/instructions/add_check_constraint/show.rb.erb +7 -0
  64. data/lib/templates/nandi/renderers/active_record/instructions/add_column/show.rb.erb +6 -0
  65. data/lib/templates/nandi/renderers/active_record/instructions/add_foreign_key/show.rb.erb +5 -0
  66. data/lib/templates/nandi/renderers/active_record/instructions/add_index/show.rb.erb +5 -0
  67. data/lib/templates/nandi/renderers/active_record/instructions/change_column_default/show.rb.erb +1 -0
  68. data/lib/templates/nandi/renderers/active_record/instructions/create_table/show.rb.erb +8 -0
  69. data/lib/templates/nandi/renderers/active_record/instructions/drop_constraint/show.rb.erb +4 -0
  70. data/lib/templates/nandi/renderers/active_record/instructions/drop_table/show.rb.erb +1 -0
  71. data/lib/templates/nandi/renderers/active_record/instructions/irreversible_migration/show.rb.erb +1 -0
  72. data/lib/templates/nandi/renderers/active_record/instructions/remove_column/show.rb.erb +5 -0
  73. data/lib/templates/nandi/renderers/active_record/instructions/remove_index/show.rb.erb +4 -0
  74. data/lib/templates/nandi/renderers/active_record/instructions/remove_not_null_constraint/show.rb.erb +1 -0
  75. data/lib/templates/nandi/renderers/active_record/instructions/validate_constraint/show.rb.erb +3 -0
  76. metadata +320 -0
@@ -0,0 +1,5 @@
1
+ add_foreign_key(
2
+ <%= table %>,
3
+ <%= target %>,
4
+ <%= extra_args %>
5
+ )
@@ -0,0 +1,5 @@
1
+ add_index(
2
+ <%= table %>,
3
+ <%= fields %>,
4
+ <%= extra_args %>
5
+ )
@@ -0,0 +1 @@
1
+ change_column_default <%= table %>, <%= column %>, <%= value %>
@@ -0,0 +1,8 @@
1
+ create_table <%= table %><% if extra_args? %>, <%= extra_args %><% end %> do |t|
2
+ <% columns.each do |column| %>
3
+ t.column <%= column.name %>, <%= column.type %><%= ", #{column.args}" if column.args %>
4
+ <% end %>
5
+ <% if timestamps? %>
6
+ t.timestamps<%= " #{timestamps_args}" if timestamps_args? %>
7
+ <% end %>
8
+ end
@@ -0,0 +1,4 @@
1
+ execute <<-SQL
2
+ ALTER TABLE <%= table %> DROP CONSTRAINT <%= name %>
3
+ SQL
4
+
@@ -0,0 +1,5 @@
1
+ remove_column(
2
+ <%= table %>,
3
+ <%= name %>,
4
+ <%= extra_args %>
5
+ )
@@ -0,0 +1,4 @@
1
+ remove_index(
2
+ <%= table %>,
3
+ <%= extra_args %>
4
+ )
@@ -0,0 +1 @@
1
+ change_column_null <%= table %>, <%= column %>, true
@@ -0,0 +1,3 @@
1
+ execute <<-SQL
2
+ ALTER TABLE <%= table %> VALIDATE CONSTRAINT <%= name %>
3
+ SQL
metadata ADDED
@@ -0,0 +1,320 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nandi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - GoCardless Engineering
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cells
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dry-monads
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tilt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '11.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '11.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: gc_ruboconfig
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.3.14
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.3.14
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 3.7.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.7.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 5.2.3
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 5.2.3
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '12.3'
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 12.3.3
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '12.3'
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 12.3.3
159
+ - !ruby/object:Gem::Dependency
160
+ name: rspec
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '3.0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '3.0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: rspec_junit_formatter
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '0.4'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '0.4'
187
+ - !ruby/object:Gem::Dependency
188
+ name: rubocop
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '0.61'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - "~>"
199
+ - !ruby/object:Gem::Version
200
+ version: '0.61'
201
+ - !ruby/object:Gem::Dependency
202
+ name: yard
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '0.9'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '0.9'
215
+ description:
216
+ email:
217
+ - engineering@gocardless.com
218
+ executables:
219
+ - nandi-enforce
220
+ extensions: []
221
+ extra_rdoc_files: []
222
+ files:
223
+ - README.md
224
+ - Rakefile
225
+ - exe/nandi-enforce
226
+ - lib/generators/nandi/check_constraint/USAGE
227
+ - lib/generators/nandi/check_constraint/check_constraint_generator.rb
228
+ - lib/generators/nandi/check_constraint/templates/add_check_constraint.rb
229
+ - lib/generators/nandi/check_constraint/templates/validate_check_constraint.rb
230
+ - lib/generators/nandi/compile/USAGE
231
+ - lib/generators/nandi/compile/compile_generator.rb
232
+ - lib/generators/nandi/foreign_key/USAGE
233
+ - lib/generators/nandi/foreign_key/foreign_key_generator.rb
234
+ - lib/generators/nandi/foreign_key/templates/add_foreign_key.rb
235
+ - lib/generators/nandi/foreign_key/templates/add_reference.rb
236
+ - lib/generators/nandi/foreign_key/templates/validate_foreign_key.rb
237
+ - lib/generators/nandi/migration/USAGE
238
+ - lib/generators/nandi/migration/migration_generator.rb
239
+ - lib/generators/nandi/migration/templates/migration.rb
240
+ - lib/generators/nandi/not_null_check/USAGE
241
+ - lib/generators/nandi/not_null_check/not_null_check_generator.rb
242
+ - lib/generators/nandi/not_null_check/templates/add_not_null_check.rb
243
+ - lib/generators/nandi/not_null_check/templates/validate_not_null_check.rb
244
+ - lib/nandi.rb
245
+ - lib/nandi/compiled_migration.rb
246
+ - lib/nandi/config.rb
247
+ - lib/nandi/file_diff.rb
248
+ - lib/nandi/file_matcher.rb
249
+ - lib/nandi/formatting.rb
250
+ - lib/nandi/instructions.rb
251
+ - lib/nandi/instructions/add_check_constraint.rb
252
+ - lib/nandi/instructions/add_column.rb
253
+ - lib/nandi/instructions/add_foreign_key.rb
254
+ - lib/nandi/instructions/add_index.rb
255
+ - lib/nandi/instructions/change_column_default.rb
256
+ - lib/nandi/instructions/create_table.rb
257
+ - lib/nandi/instructions/drop_constraint.rb
258
+ - lib/nandi/instructions/drop_table.rb
259
+ - lib/nandi/instructions/irreversible_migration.rb
260
+ - lib/nandi/instructions/remove_column.rb
261
+ - lib/nandi/instructions/remove_index.rb
262
+ - lib/nandi/instructions/remove_not_null_constraint.rb
263
+ - lib/nandi/instructions/validate_constraint.rb
264
+ - lib/nandi/lockfile.rb
265
+ - lib/nandi/migration.rb
266
+ - lib/nandi/renderers.rb
267
+ - lib/nandi/renderers/active_record.rb
268
+ - lib/nandi/renderers/active_record/generate.rb
269
+ - lib/nandi/renderers/active_record/instructions.rb
270
+ - lib/nandi/safe_migration_enforcer.rb
271
+ - lib/nandi/timeout_policies.rb
272
+ - lib/nandi/timeout_policies/access_exclusive.rb
273
+ - lib/nandi/timeout_policies/concurrent.rb
274
+ - lib/nandi/validation.rb
275
+ - lib/nandi/validation/add_column_validator.rb
276
+ - lib/nandi/validation/each_validator.rb
277
+ - lib/nandi/validation/failure_helpers.rb
278
+ - lib/nandi/validation/remove_index_validator.rb
279
+ - lib/nandi/validation/result.rb
280
+ - lib/nandi/validation/timeout_validator.rb
281
+ - lib/nandi/validator.rb
282
+ - lib/nandi/version.rb
283
+ - lib/templates/nandi/renderers/active_record/generate/show.rb.erb
284
+ - lib/templates/nandi/renderers/active_record/instructions/add_check_constraint/show.rb.erb
285
+ - lib/templates/nandi/renderers/active_record/instructions/add_column/show.rb.erb
286
+ - lib/templates/nandi/renderers/active_record/instructions/add_foreign_key/show.rb.erb
287
+ - lib/templates/nandi/renderers/active_record/instructions/add_index/show.rb.erb
288
+ - lib/templates/nandi/renderers/active_record/instructions/change_column_default/show.rb.erb
289
+ - lib/templates/nandi/renderers/active_record/instructions/create_table/show.rb.erb
290
+ - lib/templates/nandi/renderers/active_record/instructions/drop_constraint/show.rb.erb
291
+ - lib/templates/nandi/renderers/active_record/instructions/drop_table/show.rb.erb
292
+ - lib/templates/nandi/renderers/active_record/instructions/irreversible_migration/show.rb.erb
293
+ - lib/templates/nandi/renderers/active_record/instructions/remove_column/show.rb.erb
294
+ - lib/templates/nandi/renderers/active_record/instructions/remove_index/show.rb.erb
295
+ - lib/templates/nandi/renderers/active_record/instructions/remove_not_null_constraint/show.rb.erb
296
+ - lib/templates/nandi/renderers/active_record/instructions/validate_constraint/show.rb.erb
297
+ homepage: https://github.com/gocardless/nandi
298
+ licenses:
299
+ - MIT
300
+ metadata: {}
301
+ post_install_message:
302
+ rdoc_options: []
303
+ require_paths:
304
+ - lib
305
+ required_ruby_version: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - ">="
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ required_rubygems_version: !ruby/object:Gem::Requirement
311
+ requirements:
312
+ - - ">="
313
+ - !ruby/object:Gem::Version
314
+ version: '0'
315
+ requirements: []
316
+ rubygems_version: 3.0.3
317
+ signing_key:
318
+ specification_version: 4
319
+ summary: Fear-free migrations for PostgreSQL
320
+ test_files: []