ar_checked_migration 3.2 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e80d4068a08b95a03e981e6237f018feacc1c46e
4
- data.tar.gz: d46f7731357eb9af7c813e6516ed154a2d1861da
3
+ metadata.gz: dbd79cfb32baff7768069624f6b80ef19e259e06
4
+ data.tar.gz: 8791d242261a664295f154bd4e7b68c3d5e3f0b9
5
5
  SHA512:
6
- metadata.gz: b02ee3600885585dd9c1bde2b9ccbd712e3de3bd50e0907bef64e0c927498a8f4081c746f9581358337c58bdacd45a69fec66cbb17fa7e64c260ca331a198ea3
7
- data.tar.gz: e801f19de46795cb64edda6e0fb05042fc0b91e0e221082c62eaadcd7ef1c93f123140d17da28147ebbae87f6a26800d5fafede4db61998dfa718cece74faa8e
6
+ metadata.gz: 848fe38180b04093a55b3c51341ff1b6dd7fe322185aece9840ba86b79425a8c62d6eb4b8176cafe4b99ca2f6b9d8e2a1f522772d3913b0e5db326e0ee5dc1f6
7
+ data.tar.gz: 9731a65c52f8078116643c4e36b3a8c8fdc39458adf7d17276878b2fa69a6fc3a001d5ae2a2220de77c81246c8ed16d444a771e32dcc3e214b3f62070c2d3ceb
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "appraisal"
32
32
  spec.add_development_dependency "sqlite3"
33
33
 
34
- spec.add_runtime_dependency "activerecord", ">= 3.2"
34
+ spec.add_runtime_dependency "activerecord", ">= 4.0"
35
35
  end
@@ -5,32 +5,37 @@ class <%= migration_class_name %> < ActiveRecord::CheckedMigration
5
5
  <%- if migration_action == 'add' -%>
6
6
  def change
7
7
  <% attributes.each do |attribute| -%>
8
+ <%- if attribute.reference? -%>
9
+ add_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %>
10
+ <%- else -%>
8
11
  add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
9
12
  <%- if attribute.has_index? -%>
10
13
  add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
11
14
  <%- end -%>
15
+ <%- end -%>
12
16
  <%- end -%>
13
17
  end
18
+ <%- elsif migration_action == 'join' -%>
19
+ def change
20
+ create_join_table :<%= join_tables.first %>, :<%= join_tables.second %> do |t|
21
+ <%- attributes.each do |attribute| -%>
22
+ <%= '# ' unless attribute.has_index? -%>t.index <%= attribute.index_name %><%= attribute.inject_index_options %>
23
+ <%- end -%>
24
+ end
25
+ end
14
26
  <%- else -%>
15
- def up
27
+ def change
16
28
  <% attributes.each do |attribute| -%>
17
- <%- if migration_action -%>
18
- <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><%= attribute.inject_options %><% end %>
19
- <%- if attribute.has_index? && migration_action == 'add' -%>
20
- add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
29
+ <%- if migration_action -%>
30
+ <%- if attribute.reference? -%>
31
+ remove_reference :<%= table_name %>, :<%= attribute.name %><%= attribute.inject_options %>
32
+ <%- else -%>
33
+ <%- if attribute.has_index? -%>
34
+ remove_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
21
35
  <%- end -%>
36
+ remove_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
22
37
  <%- end -%>
23
38
  <%- end -%>
24
- end
25
-
26
- def down
27
- <% attributes.reverse.each do |attribute| -%>
28
- <%- if migration_action -%>
29
- <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><%= attribute.inject_options %><% end %>
30
- <%- if attribute.has_index? && migration_action == 'remove' -%>
31
- add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
32
- <%- end -%>
33
- <%- end -%>
34
39
  <%- end -%>
35
40
  end
36
41
  <%- end -%>
@@ -1,3 +1,3 @@
1
1
  module ArCheckedMigration
2
- VERSION = "3.2"
2
+ VERSION = "4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_checked_migration
3
3
  version: !ruby/object:Gem::Version
4
- version: '3.2'
4
+ version: '4.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Robertson
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - '>='
158
158
  - !ruby/object:Gem::Version
159
- version: '3.2'
159
+ version: '4.0'
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - '>='
165
165
  - !ruby/object:Gem::Version
166
- version: '3.2'
166
+ version: '4.0'
167
167
  description: |-
168
168
  Determine whether or not ActiveRecord migrations are
169
169
  considered safe to know if an app