strong_migrations 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/strong_migrations/migration.rb +14 -1
- data/lib/strong_migrations/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a340806664f60f492f6d01eef606024ac84a3fab
|
4
|
+
data.tar.gz: 64a0c246f0f557aa1bf8fe4bb3966632fdf8bd36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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:
|
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.
|
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:
|