immigrant 0.3.1 → 0.3.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 +7 -0
- data/lib/immigrant/railtie.rb +7 -2
- data/lib/immigrant/task.rb +20 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dc2d24a68bb12d527576e6b877f143f2c42bf63
|
4
|
+
data.tar.gz: 02333cc92bc40d48c3f7e043b842432ee5998e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 165a88a133f812b38899ea19b2d0fc079956d5fae1c4c2814c53569d8da37502c3c37d6052d7069c171c43a671426eecfaac49710cec5854c561d9c45e3abd03
|
7
|
+
data.tar.gz: be53c1539e0c349c76afd32136fdec1df908f15ca25357e5321f77d76d1b7768d414516dae27814339c0fc040fa387a4196944927d298364d66e18868e976819
|
data/README.md
CHANGED
@@ -28,6 +28,13 @@ evaluating the associations in your models (e.g. `belongs_to`, `has_many`, etc.)
|
|
28
28
|
Only missing keys will be added; existing ones will never be altered or
|
29
29
|
removed.
|
30
30
|
|
31
|
+
### Rake Task
|
32
|
+
|
33
|
+
To help you remember to add keys in the future, there's a handy rake
|
34
|
+
task you can add to your CI setup. Just run `rake immigrant:check_keys`,
|
35
|
+
and if anything is missing it will tell you about it and exit with a
|
36
|
+
non-zero status.
|
37
|
+
|
31
38
|
## Considerations
|
32
39
|
|
33
40
|
If the data in your tables is bad, then the migration will fail to run
|
data/lib/immigrant/railtie.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
namespace :immigrant do
|
2
|
+
desc 'Checks for missing foreign key relationships in the database'
|
3
|
+
task check_keys: :environment do
|
4
|
+
Rails.application.eager_load!
|
5
|
+
|
6
|
+
keys, warnings = Immigrant::KeyFinder.new.infer_keys
|
7
|
+
warnings.values.each { |warning| $stderr.puts "WARNING: #{warning}" }
|
8
|
+
|
9
|
+
keys.each do |key|
|
10
|
+
column = key.options[:column]
|
11
|
+
pk = key.options[:primary_key]
|
12
|
+
$stderr.puts "Missing foreign key relationship on '#{key.from_table}.#{column}' to '#{key.to_table}.#{pk}'"
|
13
|
+
end
|
14
|
+
|
15
|
+
if keys.any?
|
16
|
+
puts 'Found missing foreign keys, run `rails generate immigration MigrationName` to create a migration to add them.'
|
17
|
+
exit keys.count
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immigrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/immigrant/foreign_key_extensions.rb
|
51
51
|
- lib/immigrant/loader.rb
|
52
52
|
- lib/immigrant/railtie.rb
|
53
|
+
- lib/immigrant/task.rb
|
53
54
|
- test/compat.rb
|
54
55
|
- test/helper.rb
|
55
56
|
- test/immigrant_test.rb
|
@@ -77,3 +78,4 @@ signing_key:
|
|
77
78
|
specification_version: 4
|
78
79
|
summary: Foreign key migration generator for Rails
|
79
80
|
test_files: []
|
81
|
+
has_rdoc:
|