strong_migrations 0.1.2 → 0.1.3

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: a340806664f60f492f6d01eef606024ac84a3fab
4
- data.tar.gz: 64a0c246f0f557aa1bf8fe4bb3966632fdf8bd36
3
+ metadata.gz: bb8e5f835e883f2053abe736e2cf1f86547cb78f
4
+ data.tar.gz: d4488980ee75f4297fdc6bf0d22e0595debe0c48
5
5
  SHA512:
6
- metadata.gz: d75b1ed62073dfb24a46cf33332ec5fe5b649a36e868fe37f2837f0138e8c4b7df25b84dcec3ce84e2730b85b7d24c00feed54115b00ebab612cd78a86ae6761
7
- data.tar.gz: bce990568a87049d8834c44da5284b53d830f8ae89a0b75d0787e69a14f57d0fae5d74c4b6e534293759f7194a87bc9c3c4b8b1a4c30d30cd358d6f57d38683f
6
+ metadata.gz: 57b28bb5f980754035971fc2918d75c24e4778d7ebf8532989f3dc2a17fe5b0447388d8007bd8822713fa0bf901b33b508a3aa89c5dc718d79b78df8d1c76f60
7
+ data.tar.gz: 41f2e2e734cf6331cdabc3270d07b890a73ed323a9007e644dfa7c9124451aff656ab77d3a97cc352c8033dfb0fd61a65d6a6720f40f370968a9e8435ceb644d
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ ## 0.1.3
2
+
3
+ - Disabled dangerous rake tasks in production
4
+ - Added ability to use `SAFETY_ASSURED` env var
5
+
6
+ ## 0.1.2
7
+
8
+ - Skip checks on down migrations and rollbacks
9
+ - Added check for indexes with more than 3 columns
10
+
11
+ ## 0.1.1
12
+
13
+ - Fixed `add_index` check for MySQL
14
+
15
+ ## 0.1.0
16
+
17
+ - First release
data/README.md CHANGED
@@ -31,7 +31,7 @@ For more info, check out:
31
31
 
32
32
  Also checks for best practices:
33
33
 
34
- - keeping indexes under three columns
34
+ - keeping indexes to three columns or less
35
35
 
36
36
  ## The Zero Downtime Way
37
37
 
@@ -135,6 +135,14 @@ class MySafeMigration < ActiveRecord::Migration
135
135
  end
136
136
  ```
137
137
 
138
+ ## Production
139
+
140
+ Dangerous rake tasks are disabled in production - `db:drop`, `db:reset`, `db:schema:load`, and `db:structure:load`. To get around this, use:
141
+
142
+ ```sh
143
+ SAFETY_ASSURED=1 rake db:drop
144
+ ```
145
+
138
146
  ## Credits
139
147
 
140
148
  Thanks to Bob Remeika and David Waller for the [original code](https://github.com/foobarfighter/safe-migrations).
@@ -2,5 +2,6 @@ require "active_record"
2
2
  require "strong_migrations/version"
3
3
  require "strong_migrations/unsafe_migration"
4
4
  require "strong_migrations/migration"
5
+ require "strong_migrations/railtie" if defined?(Rails)
5
6
 
6
7
  ActiveRecord::Migration.send(:prepend, StrongMigrations::Migration)
@@ -14,7 +14,7 @@ module StrongMigrations
14
14
  end
15
15
 
16
16
  def method_missing(method, *args, &block)
17
- unless @safe || is_a?(ActiveRecord::Schema) || @direction == :down
17
+ unless @safe || ENV["SAFETY_ASSURED"] || is_a?(ActiveRecord::Schema) || @direction == :down
18
18
  case method
19
19
  when :remove_column
20
20
  raise_error :remove_column
@@ -0,0 +1,10 @@
1
+ # ensure activerecord tasks are loaded first
2
+ require "active_record/railtie"
3
+
4
+ module StrongMigrations
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load "tasks/strong_migrations.rake"
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module StrongMigrations
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,11 @@
1
+ # http://nithinbekal.com/posts/safe-rake-tasks
2
+
3
+ namespace :strong_migrations do
4
+ task safety_assured: :environment do
5
+ raise "Set SAFETY_ASSURED=1 to run this task in production" if Rails.env.production? && !ENV["SAFETY_ASSURED"]
6
+ end
7
+ end
8
+
9
+ ["db:drop", "db:reset", "db:schema:load", "db:structure:load"].each do |t|
10
+ Rake::Task[t].enhance ["strong_migrations:safety_assured"]
11
+ 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.2
4
+ version: 0.1.3
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: 2016-02-25 00:00:00.000000000 Z
13
+ date: 2016-03-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -92,14 +92,17 @@ extra_rdoc_files: []
92
92
  files:
93
93
  - ".gitignore"
94
94
  - ".travis.yml"
95
+ - CHANGELOG.md
95
96
  - Gemfile
96
97
  - LICENSE.txt
97
98
  - README.md
98
99
  - Rakefile
99
100
  - lib/strong_migrations.rb
100
101
  - lib/strong_migrations/migration.rb
102
+ - lib/strong_migrations/railtie.rb
101
103
  - lib/strong_migrations/unsafe_migration.rb
102
104
  - lib/strong_migrations/version.rb
105
+ - lib/tasks/strong_migrations.rake
103
106
  - strong_migrations.gemspec
104
107
  homepage: https://github.com/ankane/strong_migrations
105
108
  licenses: []
@@ -120,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
123
  version: '0'
121
124
  requirements: []
122
125
  rubyforge_project:
123
- rubygems_version: 2.5.2
126
+ rubygems_version: 2.6.1
124
127
  signing_key:
125
128
  specification_version: 4
126
129
  summary: Catch unsafe migrations at dev time