strong_migrations 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802c5c2d23094377d345af4b5024f7b59234c57d
4
- data.tar.gz: 5c6d8799de8f254ce8cad115f348a4f36c81b4d2
3
+ metadata.gz: a340806664f60f492f6d01eef606024ac84a3fab
4
+ data.tar.gz: 64a0c246f0f557aa1bf8fe4bb3966632fdf8bd36
5
5
  SHA512:
6
- metadata.gz: 26e985a319fb114d949a22346f276d4fc4102f370416d3a96c8adbd65192b0af8289d06e30666f54562c4638803711c6794c1abaf90273579cbab3d9a0ab6392
7
- data.tar.gz: 6c5f3aee2424a5bf1e87373c18b90f8eb71518316b817dd8b7faec715b0895065fa066c653730558ecee1a0f54db3127a6733f6568a734b5701b5da8c106b0c7
6
+ metadata.gz: d75b1ed62073dfb24a46cf33332ec5fe5b649a36e868fe37f2837f0138e8c4b7df25b84dcec3ce84e2730b85b7d24c00feed54115b00ebab612cd78a86ae6761
7
+ data.tar.gz: bce990568a87049d8834c44da5284b53d830f8ae89a0b75d0787e69a14f57d0fae5d74c4b6e534293759f7194a87bc9c3c4b8b1a4c30d30cd358d6f57d38683f
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Catch unsafe migrations at dev time
4
4
 
5
+ :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
6
+
5
7
  [![Build Status](https://travis-ci.org/ankane/strong_migrations.svg)](https://travis-ci.org/ankane/strong_migrations)
6
8
 
7
9
  ## Installation
@@ -27,6 +29,10 @@ For more info, check out:
27
29
  - [Rails Migrations with No Downtime](http://pedro.herokuapp.com/past/2011/7/13/rails_migrations_with_no_downtime/)
28
30
  - [Safe Operations For High Volume PostgreSQL](https://www.braintreepayments.com/blog/safe-operations-for-high-volume-postgresql/) (if it’s relevant)
29
31
 
32
+ Also checks for best practices:
33
+
34
+ - keeping indexes under three columns
35
+
30
36
  ## The Zero Downtime Way
31
37
 
32
38
  ### Adding a column with a default value
@@ -8,8 +8,13 @@ module StrongMigrations
8
8
  @safe = previous_value
9
9
  end
10
10
 
11
+ def migrate(direction)
12
+ @direction = direction
13
+ super
14
+ end
15
+
11
16
  def method_missing(method, *args, &block)
12
- unless @safe || is_a?(ActiveRecord::Schema)
17
+ unless @safe || is_a?(ActiveRecord::Schema) || @direction == :down
13
18
  case method
14
19
  when :remove_column
15
20
  raise_error :remove_column
@@ -22,6 +27,10 @@ module StrongMigrations
22
27
  when :rename_column
23
28
  raise_error :rename_column
24
29
  when :add_index
30
+ columns = args[1]
31
+ if columns.is_a?(Array) && columns.size > 3
32
+ raise_error :add_index_columns
33
+ end
25
34
  options = args[2]
26
35
  if %w(PostgreSQL PostGIS).include?(connection.adapter_name) && !(options && options[:algorithm] == :concurrently)
27
36
  raise_error :add_index
@@ -107,6 +116,10 @@ Once it's deployed, wrap this step in a safety_assured { ... } block."
107
116
  commit_db_transaction
108
117
  add_index :users, :some_column, algorithm: :concurrently
109
118
  end"
119
+ when :add_index_columns
120
+ "Adding an index with more than three columns only helps on extremely large tables.
121
+
122
+ If you're sure this is what you want, wrap it in a safety_assured { ... } block."
110
123
  when :change_table
111
124
  "The strong_migrations gem does not support inspecting what happens inside a
112
125
  change_table block, so cannot help you here. Please make really sure that what
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Remeika
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2015-11-29 00:00:00.000000000 Z
13
+ date: 2016-02-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -120,8 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.4.5.1
123
+ rubygems_version: 2.5.2
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Catch unsafe migrations at dev time
127
127
  test_files: []
128
+ has_rdoc: