schema_plus 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -148,6 +148,9 @@ take advantage of auto-creation of foreign keys, you can re-enable it:
148
148
 
149
149
  == History
150
150
 
151
+ * Recent Release notes:
152
+ * 0.2.1 - suppress duplicate add_indexes. compatibility with rails 3.2.0.rc2
153
+
151
154
  * SchemaPlus is derived from several "Red Hill On Rails" plugins
152
155
  originally created by harukizaemon (https://github.com/harukizaemon)
153
156
  with later contributions from
@@ -1,5 +1,5 @@
1
1
  PATH
2
- remote: /home/snatcher/projects/schema_plus
2
+ remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
4
  schema_plus (0.2.0)
5
5
  rails
@@ -19,11 +19,11 @@ GEM
19
19
  activesupport (= 2.3.14)
20
20
  activesupport (2.3.14)
21
21
  diff-lcs (1.1.3)
22
- multi_json (1.0.3)
22
+ multi_json (1.0.4)
23
23
  mysql (2.8.1)
24
- mysql2 (0.2.13)
25
- pg (0.11.0)
26
- rack (1.1.2)
24
+ mysql2 (0.2.18)
25
+ pg (0.12.2)
26
+ rack (1.1.3)
27
27
  rails (2.3.14)
28
28
  actionmailer (= 2.3.14)
29
29
  actionpack (= 2.3.14)
@@ -32,21 +32,21 @@ GEM
32
32
  activesupport (= 2.3.14)
33
33
  rake (>= 0.8.3)
34
34
  rake (0.8.7)
35
- rspec (2.6.0)
36
- rspec-core (~> 2.6.0)
37
- rspec-expectations (~> 2.6.0)
38
- rspec-mocks (~> 2.6.0)
39
- rspec-core (2.6.4)
40
- rspec-expectations (2.6.0)
35
+ rspec (2.8.0)
36
+ rspec-core (~> 2.8.0)
37
+ rspec-expectations (~> 2.8.0)
38
+ rspec-mocks (~> 2.8.0)
39
+ rspec-core (2.8.0)
40
+ rspec-expectations (2.8.0)
41
41
  diff-lcs (~> 1.1.2)
42
- rspec-mocks (2.6.0)
43
- simplecov (0.5.3)
42
+ rspec-mocks (2.8.0)
43
+ simplecov (0.5.4)
44
44
  multi_json (~> 1.0.3)
45
45
  simplecov-html (~> 0.5.3)
46
46
  simplecov-gem-adapter (1.0.1)
47
47
  simplecov
48
48
  simplecov-html (0.5.3)
49
- sqlite3 (1.3.4)
49
+ sqlite3 (1.3.5)
50
50
  valuable (0.9.2)
51
51
 
52
52
  PLATFORMS
@@ -1,5 +1,5 @@
1
1
  PATH
2
- remote: /home/snatcher/projects/schema_plus
2
+ remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
4
  schema_plus (0.2.0)
5
5
  rails
@@ -9,12 +9,12 @@ GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
11
  abstract (1.0.0)
12
- actionmailer (3.0.10)
13
- actionpack (= 3.0.10)
12
+ actionmailer (3.0.11)
13
+ actionpack (= 3.0.11)
14
14
  mail (~> 2.2.19)
15
- actionpack (3.0.10)
16
- activemodel (= 3.0.10)
17
- activesupport (= 3.0.10)
15
+ actionpack (3.0.11)
16
+ activemodel (= 3.0.11)
17
+ activesupport (= 3.0.11)
18
18
  builder (~> 2.1.2)
19
19
  erubis (~> 2.6.6)
20
20
  i18n (~> 0.5.0)
@@ -22,77 +22,79 @@ GEM
22
22
  rack-mount (~> 0.6.14)
23
23
  rack-test (~> 0.5.7)
24
24
  tzinfo (~> 0.3.23)
25
- activemodel (3.0.10)
26
- activesupport (= 3.0.10)
25
+ activemodel (3.0.11)
26
+ activesupport (= 3.0.11)
27
27
  builder (~> 2.1.2)
28
28
  i18n (~> 0.5.0)
29
- activerecord (3.0.10)
30
- activemodel (= 3.0.10)
31
- activesupport (= 3.0.10)
29
+ activerecord (3.0.11)
30
+ activemodel (= 3.0.11)
31
+ activesupport (= 3.0.11)
32
32
  arel (~> 2.0.10)
33
33
  tzinfo (~> 0.3.23)
34
- activeresource (3.0.10)
35
- activemodel (= 3.0.10)
36
- activesupport (= 3.0.10)
37
- activesupport (3.0.10)
34
+ activeresource (3.0.11)
35
+ activemodel (= 3.0.11)
36
+ activesupport (= 3.0.11)
37
+ activesupport (3.0.11)
38
38
  arel (2.0.10)
39
39
  builder (2.1.2)
40
40
  diff-lcs (1.1.3)
41
41
  erubis (2.6.6)
42
42
  abstract (>= 1.0.0)
43
43
  i18n (0.5.0)
44
+ json (1.6.4)
44
45
  mail (2.2.19)
45
46
  activesupport (>= 2.3.6)
46
47
  i18n (>= 0.4.0)
47
48
  mime-types (~> 1.16)
48
49
  treetop (~> 1.4.8)
49
- mime-types (1.16)
50
- multi_json (1.0.3)
50
+ mime-types (1.17.2)
51
+ multi_json (1.0.4)
51
52
  mysql (2.8.1)
52
- mysql2 (0.2.13)
53
- pg (0.11.0)
54
- polyglot (0.3.2)
55
- rack (1.2.4)
53
+ mysql2 (0.2.18)
54
+ pg (0.12.2)
55
+ polyglot (0.3.3)
56
+ rack (1.2.5)
56
57
  rack-mount (0.6.14)
57
58
  rack (>= 1.0.0)
58
59
  rack-test (0.5.7)
59
60
  rack (>= 1.0)
60
- rails (3.0.10)
61
- actionmailer (= 3.0.10)
62
- actionpack (= 3.0.10)
63
- activerecord (= 3.0.10)
64
- activeresource (= 3.0.10)
65
- activesupport (= 3.0.10)
61
+ rails (3.0.11)
62
+ actionmailer (= 3.0.11)
63
+ actionpack (= 3.0.11)
64
+ activerecord (= 3.0.11)
65
+ activeresource (= 3.0.11)
66
+ activesupport (= 3.0.11)
66
67
  bundler (~> 1.0)
67
- railties (= 3.0.10)
68
- railties (3.0.10)
69
- actionpack (= 3.0.10)
70
- activesupport (= 3.0.10)
68
+ railties (= 3.0.11)
69
+ railties (3.0.11)
70
+ actionpack (= 3.0.11)
71
+ activesupport (= 3.0.11)
71
72
  rake (>= 0.8.7)
72
73
  rdoc (~> 3.4)
73
74
  thor (~> 0.14.4)
74
75
  rake (0.8.7)
75
- rdoc (3.9.4)
76
- rspec (2.6.0)
77
- rspec-core (~> 2.6.0)
78
- rspec-expectations (~> 2.6.0)
79
- rspec-mocks (~> 2.6.0)
80
- rspec-core (2.6.4)
81
- rspec-expectations (2.6.0)
76
+ rdoc (3.12)
77
+ json (~> 1.4)
78
+ rspec (2.8.0)
79
+ rspec-core (~> 2.8.0)
80
+ rspec-expectations (~> 2.8.0)
81
+ rspec-mocks (~> 2.8.0)
82
+ rspec-core (2.8.0)
83
+ rspec-expectations (2.8.0)
82
84
  diff-lcs (~> 1.1.2)
83
- rspec-mocks (2.6.0)
84
- simplecov (0.5.3)
85
+ rspec-mocks (2.8.0)
86
+ simplecov (0.5.4)
85
87
  multi_json (~> 1.0.3)
86
88
  simplecov-html (~> 0.5.3)
87
89
  simplecov-gem-adapter (1.0.1)
88
90
  simplecov
89
91
  simplecov-html (0.5.3)
90
- sqlite3 (1.3.4)
92
+ sqlite3 (1.3.5)
91
93
  thor (0.14.6)
92
94
  treetop (1.4.10)
93
95
  polyglot
94
96
  polyglot (>= 0.3.1)
95
- tzinfo (0.3.29)
97
+ tzinfo (0.3.31)
96
98
  valuable (0.9.2)
97
99
 
98
100
  PLATFORMS
@@ -1,5 +1,5 @@
1
1
  PATH
2
- remote: /home/snatcher/projects/schema_plus
2
+ remote: /Users/ronen/github/schema_plus
3
3
  specs:
4
4
  schema_plus (0.2.0)
5
5
  rails
@@ -8,54 +8,53 @@ PATH
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- actionmailer (3.1.0)
12
- actionpack (= 3.1.0)
11
+ actionmailer (3.1.3)
12
+ actionpack (= 3.1.3)
13
13
  mail (~> 2.3.0)
14
- actionpack (3.1.0)
15
- activemodel (= 3.1.0)
16
- activesupport (= 3.1.0)
14
+ actionpack (3.1.3)
15
+ activemodel (= 3.1.3)
16
+ activesupport (= 3.1.3)
17
17
  builder (~> 3.0.0)
18
18
  erubis (~> 2.7.0)
19
19
  i18n (~> 0.6)
20
- rack (~> 1.3.2)
21
- rack-cache (~> 1.0.3)
20
+ rack (~> 1.3.5)
21
+ rack-cache (~> 1.1)
22
22
  rack-mount (~> 0.8.2)
23
23
  rack-test (~> 0.6.1)
24
- sprockets (~> 2.0.0)
25
- activemodel (3.1.0)
26
- activesupport (= 3.1.0)
27
- bcrypt-ruby (~> 3.0.0)
24
+ sprockets (~> 2.0.3)
25
+ activemodel (3.1.3)
26
+ activesupport (= 3.1.3)
28
27
  builder (~> 3.0.0)
29
28
  i18n (~> 0.6)
30
- activerecord (3.1.0)
31
- activemodel (= 3.1.0)
32
- activesupport (= 3.1.0)
29
+ activerecord (3.1.3)
30
+ activemodel (= 3.1.3)
31
+ activesupport (= 3.1.3)
33
32
  arel (~> 2.2.1)
34
33
  tzinfo (~> 0.3.29)
35
- activeresource (3.1.0)
36
- activemodel (= 3.1.0)
37
- activesupport (= 3.1.0)
38
- activesupport (3.1.0)
34
+ activeresource (3.1.3)
35
+ activemodel (= 3.1.3)
36
+ activesupport (= 3.1.3)
37
+ activesupport (3.1.3)
39
38
  multi_json (~> 1.0)
40
39
  arel (2.2.1)
41
- bcrypt-ruby (3.0.1)
42
40
  builder (3.0.0)
43
41
  diff-lcs (1.1.3)
44
42
  erubis (2.7.0)
45
43
  hike (1.2.1)
46
44
  i18n (0.6.0)
45
+ json (1.6.4)
47
46
  mail (2.3.0)
48
47
  i18n (>= 0.4.0)
49
48
  mime-types (~> 1.16)
50
49
  treetop (~> 1.4.8)
51
- mime-types (1.16)
52
- multi_json (1.0.3)
50
+ mime-types (1.17.2)
51
+ multi_json (1.0.4)
53
52
  mysql (2.8.1)
54
- mysql2 (0.3.7)
55
- pg (0.11.0)
56
- polyglot (0.3.2)
57
- rack (1.3.3)
58
- rack-cache (1.0.3)
53
+ mysql2 (0.3.11)
54
+ pg (0.12.2)
55
+ polyglot (0.3.3)
56
+ rack (1.3.6)
57
+ rack-cache (1.1)
59
58
  rack (>= 0.4)
60
59
  rack-mount (0.8.3)
61
60
  rack (>= 1.0.0)
@@ -63,48 +62,49 @@ GEM
63
62
  rack
64
63
  rack-test (0.6.1)
65
64
  rack (>= 1.0)
66
- rails (3.1.0)
67
- actionmailer (= 3.1.0)
68
- actionpack (= 3.1.0)
69
- activerecord (= 3.1.0)
70
- activeresource (= 3.1.0)
71
- activesupport (= 3.1.0)
65
+ rails (3.1.3)
66
+ actionmailer (= 3.1.3)
67
+ actionpack (= 3.1.3)
68
+ activerecord (= 3.1.3)
69
+ activeresource (= 3.1.3)
70
+ activesupport (= 3.1.3)
72
71
  bundler (~> 1.0)
73
- railties (= 3.1.0)
74
- railties (3.1.0)
75
- actionpack (= 3.1.0)
76
- activesupport (= 3.1.0)
72
+ railties (= 3.1.3)
73
+ railties (3.1.3)
74
+ actionpack (= 3.1.3)
75
+ activesupport (= 3.1.3)
77
76
  rack-ssl (~> 1.3.2)
78
77
  rake (>= 0.8.7)
79
78
  rdoc (~> 3.4)
80
79
  thor (~> 0.14.6)
81
80
  rake (0.8.7)
82
- rdoc (3.9.4)
83
- rspec (2.6.0)
84
- rspec-core (~> 2.6.0)
85
- rspec-expectations (~> 2.6.0)
86
- rspec-mocks (~> 2.6.0)
87
- rspec-core (2.6.4)
88
- rspec-expectations (2.6.0)
81
+ rdoc (3.12)
82
+ json (~> 1.4)
83
+ rspec (2.8.0)
84
+ rspec-core (~> 2.8.0)
85
+ rspec-expectations (~> 2.8.0)
86
+ rspec-mocks (~> 2.8.0)
87
+ rspec-core (2.8.0)
88
+ rspec-expectations (2.8.0)
89
89
  diff-lcs (~> 1.1.2)
90
- rspec-mocks (2.6.0)
91
- simplecov (0.5.3)
90
+ rspec-mocks (2.8.0)
91
+ simplecov (0.5.4)
92
92
  multi_json (~> 1.0.3)
93
93
  simplecov-html (~> 0.5.3)
94
94
  simplecov-gem-adapter (1.0.1)
95
95
  simplecov
96
96
  simplecov-html (0.5.3)
97
- sprockets (2.0.0)
97
+ sprockets (2.0.3)
98
98
  hike (~> 1.2)
99
99
  rack (~> 1.0)
100
100
  tilt (~> 1.1, != 1.3.0)
101
- sqlite3 (1.3.4)
101
+ sqlite3 (1.3.5)
102
102
  thor (0.14.6)
103
103
  tilt (1.3.3)
104
104
  treetop (1.4.10)
105
105
  polyglot
106
106
  polyglot (>= 0.3.1)
107
- tzinfo (0.3.29)
107
+ tzinfo (0.3.31)
108
108
  valuable (0.9.2)
109
109
 
110
110
  PLATFORMS
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => File.expand_path('../..', __FILE__)
4
+ gem "rails", "~> 3.2.0.rc2"
5
+ gem "mysql2"
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: /Users/ronen/github/schema_plus
3
+ specs:
4
+ schema_plus (0.2.0)
5
+ rails
6
+ valuable
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.2.0.rc2)
12
+ actionpack (= 3.2.0.rc2)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.2.0.rc2)
15
+ activemodel (= 3.2.0.rc2)
16
+ activesupport (= 3.2.0.rc2)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.0.rc1)
20
+ rack (~> 1.4.0)
21
+ rack-cache (~> 1.1)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.1.2)
24
+ activemodel (3.2.0.rc2)
25
+ activesupport (= 3.2.0.rc2)
26
+ builder (~> 3.0.0)
27
+ activerecord (3.2.0.rc2)
28
+ activemodel (= 3.2.0.rc2)
29
+ activesupport (= 3.2.0.rc2)
30
+ arel (~> 3.0.0.rc1)
31
+ tzinfo (~> 0.3.29)
32
+ activeresource (3.2.0.rc2)
33
+ activemodel (= 3.2.0.rc2)
34
+ activesupport (= 3.2.0.rc2)
35
+ activesupport (3.2.0.rc2)
36
+ i18n (~> 0.6)
37
+ multi_json (~> 1.0)
38
+ arel (3.0.0.rc1)
39
+ builder (3.0.0)
40
+ diff-lcs (1.1.3)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.0.rc4)
45
+ json (1.6.4)
46
+ mail (2.3.0)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.17.2)
51
+ multi_json (1.0.4)
52
+ mysql (2.8.1)
53
+ mysql2 (0.3.11)
54
+ pg (0.12.2)
55
+ polyglot (0.3.3)
56
+ rack (1.4.0)
57
+ rack-cache (1.1)
58
+ rack (>= 0.4)
59
+ rack-ssl (1.3.2)
60
+ rack
61
+ rack-test (0.6.1)
62
+ rack (>= 1.0)
63
+ rails (3.2.0.rc2)
64
+ actionmailer (= 3.2.0.rc2)
65
+ actionpack (= 3.2.0.rc2)
66
+ activerecord (= 3.2.0.rc2)
67
+ activeresource (= 3.2.0.rc2)
68
+ activesupport (= 3.2.0.rc2)
69
+ bundler (~> 1.0)
70
+ railties (= 3.2.0.rc2)
71
+ railties (3.2.0.rc2)
72
+ actionpack (= 3.2.0.rc2)
73
+ activesupport (= 3.2.0.rc2)
74
+ rack-ssl (~> 1.3.2)
75
+ rake (>= 0.8.7)
76
+ rdoc (~> 3.4)
77
+ thor (~> 0.14.6)
78
+ rake (0.8.7)
79
+ rdoc (3.12)
80
+ json (~> 1.4)
81
+ rspec (2.8.0)
82
+ rspec-core (~> 2.8.0)
83
+ rspec-expectations (~> 2.8.0)
84
+ rspec-mocks (~> 2.8.0)
85
+ rspec-core (2.8.0)
86
+ rspec-expectations (2.8.0)
87
+ diff-lcs (~> 1.1.2)
88
+ rspec-mocks (2.8.0)
89
+ simplecov (0.5.4)
90
+ multi_json (~> 1.0.3)
91
+ simplecov-html (~> 0.5.3)
92
+ simplecov-gem-adapter (1.0.1)
93
+ simplecov
94
+ simplecov-html (0.5.3)
95
+ sprockets (2.1.2)
96
+ hike (~> 1.2)
97
+ rack (~> 1.0)
98
+ tilt (~> 1.1, != 1.3.0)
99
+ sqlite3 (1.3.5)
100
+ thor (0.14.6)
101
+ tilt (1.3.3)
102
+ treetop (1.4.10)
103
+ polyglot
104
+ polyglot (>= 0.3.1)
105
+ tzinfo (0.3.31)
106
+ valuable (0.9.2)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ mysql
113
+ mysql2
114
+ pg
115
+ rails (~> 3.2.0.rc2)
116
+ rake (~> 0.8.7)
117
+ rspec
118
+ schema_plus!
119
+ simplecov
120
+ simplecov-gem-adapter
121
+ sqlite3
@@ -96,10 +96,16 @@ module SchemaPlus
96
96
  end
97
97
 
98
98
  def drop_table_with_schema_plus(name, options = {}) #:nodoc:
99
+ # (NOTE: rails 3.2 accepts only one arg, no options. pre rails
100
+ # 3.2, drop_table took an options={} arg that had no effect: but
101
+ # create_table(:force=>true) would call drop_table with two args.
102
+ # so for backwards compatibility, schema_plus drop_table accepts
103
+ # two args. but for forward compatibility with rails 3.2, the
104
+ # second arg is not passed along to rails.)
99
105
  unless ::ActiveRecord::Base.connection.class.include?(SchemaPlus::ActiveRecord::ConnectionAdapters::Sqlite3Adapter)
100
106
  reverse_foreign_keys(name).each { |foreign_key| remove_foreign_key(foreign_key.table_name, foreign_key.name) }
101
107
  end
102
- drop_table_without_schema_plus(name, options)
108
+ drop_table_without_schema_plus(name)
103
109
  end
104
110
 
105
111
  # Returns true if the database supports parital indexes (abstract; only
@@ -45,6 +45,19 @@ module SchemaPlus
45
45
  opts[:case_sensitive] = case_sensitive? unless @case_sensitive.nil?
46
46
  opts
47
47
  end
48
+
49
+ # tests if the corresponding indexes would be the same
50
+ def ==(other)
51
+ return false unless self.name == other.name
52
+ return false unless Array.wrap(self.columns).collect(&:to_s).sort == Array.wrap(other.columns).collect(&:to_s).sort
53
+ return false unless !!self.unique == !!other.unique
54
+ return false unless Array.wrap(self.lengths).compact.sort == Array.wrap(other.lengths).compact.sort
55
+ return false unless self.conditions == other.conditions
56
+ return false unless self.expression == other.expression
57
+ return false unless self.kind == other.kind
58
+ return false unless !!self.case_sensitive? == !!other.case_sensitive?
59
+ true
60
+ end
48
61
  end
49
62
  end
50
63
  end
@@ -42,6 +42,8 @@ module SchemaPlus
42
42
  sql += " WHERE (#{ ::ActiveRecord::Base.send(:sanitize_sql, conditions, quote_table_name(table_name)) })" if conditions
43
43
  end
44
44
  execute sql
45
+ rescue => e
46
+ SchemaStatements.add_index_exception_handler(self, table_name, column_names, options, e)
45
47
  end
46
48
 
47
49
  def supports_partial_indexes? #:nodoc:
@@ -4,6 +4,7 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
4
4
  def self.included(base) #:nodoc:
5
5
  base.class_eval do
6
6
  alias_method_chain :create_table, :schema_plus
7
+ alias_method_chain :add_index, :schema_plus
7
8
  end
8
9
  end
9
10
 
@@ -31,8 +32,35 @@ module SchemaPlus::ActiveRecord::ConnectionAdapters
31
32
  indexes.each do |index|
32
33
  add_index(table, index.columns, index.opts)
33
34
  end
35
+ end
34
36
 
37
+ ##
38
+ # :method: add_index
39
+ #
40
+ # SchemaPlus modifies SchemaStatements::add_index so that it ignores
41
+ # errors raised about add an index that already exists -- i.e. that has
42
+ # the same index name, same columns, and same options -- and writes a
43
+ # warning to the log. Some combinations of rails & DB adapter versions
44
+ # would log such a warning, others would raise an error; with
45
+ # SchemaPlus all versions log the warning and do not raise the error.
46
+ #
47
+ # (This avoids collisions between SchemaPlus's auto index behavior and
48
+ # legacy explicit add_index statements, for platforms that would raise
49
+ # an error.)
50
+ #
51
+ def add_index_with_schema_plus(table, columns, options={})
52
+ add_index_without_schema_plus(table, columns, options)
53
+ rescue => e
54
+ SchemaStatements.add_index_exception_handler(self, table, columns, options, e)
55
+ end
35
56
 
57
+ def self.add_index_exception_handler(connection, table, columns, options, e) #:nodoc:
58
+ raise unless e.message.match(/["']([^"']+)["'].*already exists/)
59
+ name = $1
60
+ existing = connection.indexes(table).find{|i| i.name == name}
61
+ attempted = ::ActiveRecord::ConnectionAdapters::IndexDefinition.new(table, columns, options.merge(:name => name))
62
+ raise if attempted != existing
63
+ ::ActiveRecord::Base.logger.warn "[schema_plus] Index name #{name.inspect}' on table #{table.inspect} already exists. Skipping."
36
64
  end
37
65
 
38
66
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/runspecs CHANGED
@@ -4,7 +4,7 @@ require 'optparse'
4
4
  require 'ostruct'
5
5
 
6
6
  RUBY_VERSIONS = %W[1.8.7 1.9.2]
7
- RAILS_VERSIONS = %W[2.3 3.0 3.1]
7
+ RAILS_VERSIONS = %W[2.3 3.0 3.1 3.2]
8
8
  DB_ADAPTERS = %W[postgresql mysql mysql2 sqlite3]
9
9
 
10
10
  o = OpenStruct.new
@@ -53,28 +53,43 @@ OptionParser.new do |opts|
53
53
 
54
54
  end.parse!
55
55
 
56
- cmd = case
57
- when o.update
58
- "bundle update"
59
- when o.install
60
- "bundle install"
61
- else
62
- "bundle exec rake #{o.db_adapters.join(":spec ")}:spec"
63
- end
64
56
 
65
- n = 1
57
+ Combo = Struct.new(:ruby, :rails, :db_adapter)
58
+
59
+
60
+ if o.update or o.install
61
+ o.db_adapters = [nil]
62
+ end
63
+
64
+ combos = o.ruby_versions.product(o.rails_versions, o.db_adapters).map{|product| Combo.new(*product)}.select {|combo|
65
+ case
66
+ when combo.rails >= "3.2" && combo.ruby <= "1.8.7" then false
67
+ else true
68
+ end
69
+ }
70
+
71
+
66
72
  GEMFILES_DIR = File.expand_path('../gemfiles', __FILE__)
67
- total = o.ruby_versions.size * o.rails_versions.size
68
73
  errs = []
69
- o.ruby_versions.each do |ruby|
70
- o.rails_versions.each do |rails|
71
- puts "\n\n*** ruby version #{ruby} - rails version #{rails} - db adapters: #{o.db_adapters.join(' ')} [#{n} of #{total}]\n\n"
72
- gemfile = File.join(GEMFILES_DIR, "Gemfile.rails-#{rails}")
73
- n += 1
74
- command = %Q{BUNDLE_GEMFILE="#{gemfile}" rvm #{ruby} do #{cmd}}
75
- puts command
76
- next if o.dry_run
77
- system(command) or errs << "ruby #{ruby}, rails #{rails}"
78
- end
74
+ combos.each_with_index do |combo, n|
75
+ ruby = combo.ruby
76
+ rails = combo.rails
77
+ db_adapter = combo.db_adapter
78
+
79
+ cmd = case
80
+ when o.update
81
+ "bundle update"
82
+ when o.install
83
+ "bundle install"
84
+ else
85
+ "bundle exec rake #{db_adapter}:spec"
86
+ end
87
+
88
+ command = %Q{BUNDLE_GEMFILE="#{File.join(GEMFILES_DIR, "Gemfile.rails-#{rails}")}" rvm #{ruby} do #{cmd}}
89
+
90
+ puts "\n\n*** ruby version #{ruby} - rails version #{rails} - db adapter: #{db_adapter} [#{n+1} of #{combos.size}]\n\n#{command}"
91
+
92
+ next if o.dry_run
93
+ system(command) or errs << "ruby #{ruby}, rails #{rails}#{db_adapter && ", db_adapter #{db_adapter}"}"
79
94
  end
80
- puts errs.any? ? "\n*** #{errs.size} failures:\n\t#{errs.join("\n\t")}" : "\n*** #{total > 1 ? 'all versions' : 'spec'} succeeded ***" unless o.dry_run
95
+ puts errs.any? ? "\n*** #{errs.size} failures:\n\t#{errs.join("\n\t")}" : "\n*** #{combos.size > 1 ? 'all versions' : 'spec'} succeeded ***" unless o.dry_run
data/spec/index_spec.rb CHANGED
@@ -31,6 +31,24 @@ describe "add_index" do
31
31
  index_for(:login).name.should == 'users_login_index'
32
32
  end
33
33
 
34
+ context "for duplicate index" do
35
+ it "should not complain if the index is the same" do
36
+ add_index(:users, :login)
37
+ index_for(:login).should_not be_nil
38
+ ActiveRecord::Base.logger.should_receive(:warn).with(/login.*Skipping/)
39
+ expect { add_index(:users, :login) }.should_not raise_error
40
+ index_for(:login).should_not be_nil
41
+ end
42
+ if defined? Rails and Rails.version >= "3.0"
43
+ it "should complain if the index is different" do
44
+ add_index(:users, :login, :unique => true)
45
+ index_for(:login).should_not be_nil
46
+ expect { add_index(:users, :login) }.should raise_error
47
+ index_for(:login).should_not be_nil
48
+ end
49
+ end
50
+ end
51
+
34
52
  if SchemaPlusHelpers.postgresql?
35
53
 
36
54
  it "should assign conditions" do
metadata CHANGED
@@ -1,144 +1,126 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: schema_plus
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ronen Barzel
13
9
  - Michal Lomnicki
14
10
  autorequire:
15
11
  bindir: bin
16
12
  cert_chain: []
17
-
18
- date: 2011-10-22 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2012-01-06 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
17
+ requirement: &70342781866240 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
31
23
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: valuable
35
24
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- version: "0"
25
+ version_requirements: *70342781866240
26
+ - !ruby/object:Gem::Dependency
27
+ name: valuable
28
+ requirement: &70342781865820 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
43
34
  type: :runtime
44
- version_requirements: *id002
45
- - !ruby/object:Gem::Dependency
46
- name: rake
47
35
  prerelease: false
48
- requirement: &id003 !ruby/object:Gem::Requirement
49
- requirements:
36
+ version_requirements: *70342781865820
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &70342781865300 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
50
42
  - - ~>
51
- - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
- - 8
55
- - 7
43
+ - !ruby/object:Gem::Version
56
44
  version: 0.8.7
57
45
  type: :development
58
- version_requirements: *id003
59
- - !ruby/object:Gem::Dependency
60
- name: rspec
61
46
  prerelease: false
62
- requirement: &id004 !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
- version: "0"
47
+ version_requirements: *70342781865300
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: &70342781864880 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
69
56
  type: :development
70
- version_requirements: *id004
71
- - !ruby/object:Gem::Dependency
72
- name: pg
73
57
  prerelease: false
74
- requirement: &id005 !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
- version: "0"
58
+ version_requirements: *70342781864880
59
+ - !ruby/object:Gem::Dependency
60
+ name: pg
61
+ requirement: &70342781864320 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
81
67
  type: :development
82
- version_requirements: *id005
83
- - !ruby/object:Gem::Dependency
84
- name: mysql
85
68
  prerelease: false
86
- requirement: &id006 !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- segments:
91
- - 0
92
- version: "0"
69
+ version_requirements: *70342781864320
70
+ - !ruby/object:Gem::Dependency
71
+ name: mysql
72
+ requirement: &70342781863720 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
93
78
  type: :development
94
- version_requirements: *id006
95
- - !ruby/object:Gem::Dependency
96
- name: sqlite3
97
79
  prerelease: false
98
- requirement: &id007 !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- segments:
103
- - 0
104
- version: "0"
80
+ version_requirements: *70342781863720
81
+ - !ruby/object:Gem::Dependency
82
+ name: sqlite3
83
+ requirement: &70342781863120 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
105
89
  type: :development
106
- version_requirements: *id007
107
- - !ruby/object:Gem::Dependency
108
- name: simplecov
109
90
  prerelease: false
110
- requirement: &id008 !ruby/object:Gem::Requirement
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- segments:
115
- - 0
116
- version: "0"
91
+ version_requirements: *70342781863120
92
+ - !ruby/object:Gem::Dependency
93
+ name: simplecov
94
+ requirement: &70342781862620 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
117
100
  type: :development
118
- version_requirements: *id008
119
- - !ruby/object:Gem::Dependency
120
- name: simplecov-gem-adapter
121
101
  prerelease: false
122
- requirement: &id009 !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- segments:
127
- - 0
128
- version: "0"
102
+ version_requirements: *70342781862620
103
+ - !ruby/object:Gem::Dependency
104
+ name: simplecov-gem-adapter
105
+ requirement: &70342781862160 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
129
111
  type: :development
130
- version_requirements: *id009
131
- description: "SchemaPlus is an ActiveRecord extension that provides enhanced capabilities for schema definition and querying, including: enhanced and more DRY index capabilities, support and automation for foreign key constraints, and support for views."
132
- email:
112
+ prerelease: false
113
+ version_requirements: *70342781862160
114
+ description: ! 'SchemaPlus is an ActiveRecord extension that provides enhanced capabilities
115
+ for schema definition and querying, including: enhanced and more DRY index capabilities,
116
+ support and automation for foreign key constraints, and support for views.'
117
+ email:
133
118
  - ronen@barzel.org
134
119
  - michal.lomnicki@gmail.com
135
120
  executables: []
136
-
137
121
  extensions: []
138
-
139
122
  extra_rdoc_files: []
140
-
141
- files:
123
+ files:
142
124
  - .gitignore
143
125
  - .travis.yml
144
126
  - Gemfile
@@ -151,6 +133,8 @@ files:
151
133
  - gemfiles/Gemfile.rails-3.0.lock
152
134
  - gemfiles/Gemfile.rails-3.1
153
135
  - gemfiles/Gemfile.rails-3.1.lock
136
+ - gemfiles/Gemfile.rails-3.2
137
+ - gemfiles/Gemfile.rails-3.2.lock
154
138
  - init.rb
155
139
  - lib/rails/tasks/database.rake
156
140
  - lib/schema_plus.rb
@@ -198,35 +182,55 @@ files:
198
182
  - spec/support/matchers/reference.rb
199
183
  - spec/support/reference.rb
200
184
  - spec/views_spec.rb
201
- has_rdoc: true
202
185
  homepage: https://github.com/lomba/schema_plus
203
186
  licenses: []
204
-
205
187
  post_install_message:
206
188
  rdoc_options: []
207
-
208
- require_paths:
189
+ require_paths:
209
190
  - lib
210
- required_ruby_version: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - ">="
213
- - !ruby/object:Gem::Version
214
- segments:
215
- - 0
216
- version: "0"
217
- required_rubygems_version: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- segments:
222
- - 0
223
- version: "0"
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ! '>='
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ required_rubygems_version: !ruby/object:Gem::Requirement
198
+ none: false
199
+ requirements:
200
+ - - ! '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
224
203
  requirements: []
225
-
226
204
  rubyforge_project: schema_plus
227
- rubygems_version: 1.3.6
205
+ rubygems_version: 1.8.12
228
206
  signing_key:
229
207
  specification_version: 3
230
- summary: Enhances ActiveRecord schema mechanism, including more DRY index creation and support for foreign key constraints and views.
231
- test_files: []
232
-
208
+ summary: Enhances ActiveRecord schema mechanism, including more DRY index creation
209
+ and support for foreign key constraints and views.
210
+ test_files:
211
+ - spec/column_spec.rb
212
+ - spec/connection_spec.rb
213
+ - spec/connections/mysql/connection.rb
214
+ - spec/connections/mysql2/connection.rb
215
+ - spec/connections/postgresql/connection.rb
216
+ - spec/connections/sqlite3/connection.rb
217
+ - spec/foreign_key_definition_spec.rb
218
+ - spec/foreign_key_spec.rb
219
+ - spec/index_definition_spec.rb
220
+ - spec/index_spec.rb
221
+ - spec/migration_spec.rb
222
+ - spec/models/comment.rb
223
+ - spec/models/post.rb
224
+ - spec/models/user.rb
225
+ - spec/rails3_migration_spec.rb
226
+ - spec/schema/auto_schema.rb
227
+ - spec/schema/core_schema.rb
228
+ - spec/schema_dumper_spec.rb
229
+ - spec/schema_spec.rb
230
+ - spec/spec_helper.rb
231
+ - spec/support/helpers.rb
232
+ - spec/support/matchers/automatic_foreign_key_matchers.rb
233
+ - spec/support/matchers/have_index.rb
234
+ - spec/support/matchers/reference.rb
235
+ - spec/support/reference.rb
236
+ - spec/views_spec.rb