schema_plus 2.0.0.pre9 → 2.0.0.pre10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/README.md +2 -21
- data/gemfiles/{activerecord-4.2 → activerecord-4.2.0}/Gemfile.base +1 -1
- data/gemfiles/{activerecord-4.2 → activerecord-4.2.0}/Gemfile.mysql2 +0 -0
- data/gemfiles/{activerecord-4.2 → activerecord-4.2.0}/Gemfile.postgresql +0 -0
- data/gemfiles/{activerecord-4.2 → activerecord-4.2.0}/Gemfile.sqlite3 +0 -0
- data/gemfiles/activerecord-4.2.1/Gemfile.base +3 -0
- data/gemfiles/activerecord-4.2.1/Gemfile.mysql2 +10 -0
- data/gemfiles/activerecord-4.2.1/Gemfile.postgresql +10 -0
- data/gemfiles/activerecord-4.2.1/Gemfile.sqlite3 +10 -0
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/foreign_key_definition.rb +0 -1
- data/lib/schema_plus/foreign_keys/active_record/connection_adapters/table_definition.rb +6 -2
- data/lib/schema_plus/foreign_keys/middleware/migration.rb +7 -2
- data/lib/schema_plus/foreign_keys/middleware/sql.rb +10 -1
- data/lib/schema_plus/version.rb +1 -1
- data/schema_dev.yml +2 -1
- data/schema_plus.gemspec +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c5aee9479eef0756986536130a26f38f23c4a87
|
4
|
+
data.tar.gz: 4447fc06494c1646f8587f11882751618fc9f4cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 235927976009fd939faa6180f2465a12aa03db03263f310428c94e2d23bb3ba9c86e9343cc2dcdd4a12bead0ed058f9b84ce61d13e9ec06f1cdda719e768b5f5
|
7
|
+
data.tar.gz: fb6d3574efc491cdf8d4e344a0c554f051ee072fae6a3050ecdc5e32cb2021daec0acf8076f86d43aec0ccf3ae75c3558ef7a451142414886e6b5303512229d1
|
data/.travis.yml
CHANGED
@@ -7,9 +7,12 @@ sudo: false
|
|
7
7
|
rvm:
|
8
8
|
- 2.1.5
|
9
9
|
gemfile:
|
10
|
-
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
11
|
-
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
12
|
-
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
10
|
+
- gemfiles/activerecord-4.2.0/Gemfile.mysql2
|
11
|
+
- gemfiles/activerecord-4.2.0/Gemfile.postgresql
|
12
|
+
- gemfiles/activerecord-4.2.0/Gemfile.sqlite3
|
13
|
+
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
14
|
+
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
15
|
+
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
13
16
|
env: POSTGRESQL_DB_USER=postgres MYSQL_DB_USER=travis
|
14
17
|
addons:
|
15
18
|
postgresql: '9.3'
|
data/README.md
CHANGED
@@ -81,7 +81,8 @@ SchemaPlus 2.x is tested against all combinations of:
|
|
81
81
|
|
82
82
|
<!-- SCHEMA_DEV: MATRIX - begin -->
|
83
83
|
<!-- These lines are auto-generated by schema_dev based on schema_dev.yml -->
|
84
|
-
* ruby **2.1.5** with activerecord **4.2**, using **mysql2**, **sqlite3** or **postgresql**
|
84
|
+
* ruby **2.1.5** with activerecord **4.2.0**, using **mysql2**, **sqlite3** or **postgresql**
|
85
|
+
* ruby **2.1.5** with activerecord **4.2.1**, using **mysql2**, **sqlite3** or **postgresql**
|
85
86
|
|
86
87
|
<!-- SCHEMA_DEV: MATRIX - end -->
|
87
88
|
|
@@ -227,26 +228,6 @@ Note that after updating, you would need to reload a record to replace
|
|
227
228
|
Note also that Sqlite3 does not support `ActiveRecord::DB_DEFAULT`; attempting
|
228
229
|
to use it will raise `ActiveRecord::StatementInvalid`
|
229
230
|
|
230
|
-
### Enums (PostgreSQL only)
|
231
|
-
|
232
|
-
SchemaPlus provides support for creating, altering and dropping enums. In a migration,
|
233
|
-
a enum can be created:
|
234
|
-
|
235
|
-
create_enum :color, :red, :green, :blue # default schema is 'public'
|
236
|
-
create_enum :cmyk, :cyan, :magenta, :yellow, :black, :schema => 'color'
|
237
|
-
|
238
|
-
And can be altered: (added a new value)
|
239
|
-
|
240
|
-
alter_enum :color, :black
|
241
|
-
alter_enum :color, :purple, :after => 'red'
|
242
|
-
alter_enum :color, :pink, :before => 'purple'
|
243
|
-
alter_enum :color, :white, :schema => 'public'
|
244
|
-
|
245
|
-
Finally, a enum can be dropped:
|
246
|
-
|
247
|
-
drop_enum :color
|
248
|
-
drop_enum :cmyk, :schema => 'color'
|
249
|
-
|
250
231
|
### Schema Dump and Load (schema.rb)
|
251
232
|
|
252
233
|
When dumping `schema.rb`, SchemaPlus orders the views and tables in the schema
|
File without changes
|
File without changes
|
File without changes
|
data/lib/schema_plus/foreign_keys/active_record/connection_adapters/foreign_key_definition.rb
CHANGED
@@ -43,7 +43,6 @@ module SchemaPlus::ForeignKeys
|
|
43
43
|
def initialize(from_table, to_table, options={})
|
44
44
|
[:on_update, :on_delete].each do |key|
|
45
45
|
if options[key] == :set_null
|
46
|
-
require 'byebug' ; byebug
|
47
46
|
ActiveSupport::Deprecation.warn ":set_null value for #{key} is deprecated. use :nullify instead"
|
48
47
|
options[key] = :nullify
|
49
48
|
end
|
@@ -69,7 +69,7 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
|
|
69
69
|
|
70
70
|
def foreign_keys
|
71
71
|
@foreign_keys ||= []
|
72
|
-
end
|
72
|
+
end if ActiveRecord.version == Gem::Version.new("4.2.0")
|
73
73
|
|
74
74
|
def foreign_key(*args) # (column_names, to_table, primary_key=nil, options=nil)
|
75
75
|
options = args.extract_options!
|
@@ -89,7 +89,11 @@ module SchemaPlus::ForeignKeys::ActiveRecord::ConnectionAdapters
|
|
89
89
|
|
90
90
|
options.merge!(:column => column_names)
|
91
91
|
options.reverse_merge!(:name => ForeignKeyDefinition.default_name(self.name, column_names))
|
92
|
-
|
92
|
+
fk = ::ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(self.name, AbstractAdapter.proper_table_name(to_table), options)
|
93
|
+
case ::ActiveRecord.version
|
94
|
+
when Gem::Version.new("4.2.0") then foreign_keys << fk
|
95
|
+
else foreign_keys[fk.to_table] = fk
|
96
|
+
end
|
93
97
|
self
|
94
98
|
end
|
95
99
|
|
@@ -64,7 +64,10 @@ module SchemaPlus::ForeignKeys
|
|
64
64
|
# usurp index creation from AR. That's necessary to make
|
65
65
|
# auto_index work properly
|
66
66
|
index = options.delete(:index) unless is_polymorphic
|
67
|
-
|
67
|
+
if is_reference
|
68
|
+
options[:foreign_key] = false
|
69
|
+
options[:_is_reference] = true
|
70
|
+
end
|
68
71
|
|
69
72
|
yield env
|
70
73
|
|
@@ -145,7 +148,9 @@ module SchemaPlus::ForeignKeys
|
|
145
148
|
return :none if options[:foreign_key] == false
|
146
149
|
|
147
150
|
args = options[:foreign_key]
|
148
|
-
|
151
|
+
auto = config.auto_create?
|
152
|
+
auto = false if options[:_is_reference] and env.type != :reference # this is a nested call to column() from with reference(); suppress auto-fk
|
153
|
+
args ||= {} if auto and column_name =~ /_id$/
|
149
154
|
|
150
155
|
return nil if args.nil?
|
151
156
|
|
@@ -3,7 +3,16 @@ module SchemaPlus::ForeignKeys
|
|
3
3
|
module Sql
|
4
4
|
module Table
|
5
5
|
def after(env)
|
6
|
-
|
6
|
+
foreign_keys = case ::ActiveRecord.version
|
7
|
+
when Gem::Version.new("4.2.0") then env.table_definition.foreign_keys
|
8
|
+
else env.table_definition.foreign_keys.values
|
9
|
+
end
|
10
|
+
|
11
|
+
# create foreign key constraints inline in table definition
|
12
|
+
env.sql.body = ([env.sql.body] + foreign_keys.map(&:to_sql)).join(', ')
|
13
|
+
|
14
|
+
# prevents AR >= 4.2.1 from emitting add_foreign_key after the table
|
15
|
+
env.table_definition.foreign_keys.clear
|
7
16
|
end
|
8
17
|
end
|
9
18
|
end
|
data/lib/schema_plus/version.rb
CHANGED
data/schema_dev.yml
CHANGED
data/schema_plus.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
|
|
32
32
|
gem.add_dependency "schema_plus_tables", "~> 0.1"
|
33
33
|
gem.add_dependency "schema_plus_views", "~> 0.1"
|
34
34
|
|
35
|
-
gem.add_development_dependency "schema_dev", "~> 3.
|
35
|
+
gem.add_development_dependency "schema_dev", "~> 3.4"
|
36
36
|
gem.add_development_dependency "rake"
|
37
37
|
gem.add_development_dependency "rspec", "~> 3.0"
|
38
38
|
gem.add_development_dependency "rdoc"
|
data/spec/spec_helper.rb
CHANGED
@@ -59,5 +59,5 @@ def remove_all_models
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
SimpleCov.command_name "[ruby
|
62
|
+
SimpleCov.command_name "[ruby#{RUBY_VERSION}-activerecord#{::ActiveRecord::VERSION::STRING}-#{ActiveRecord::Base.connection.adapter_name}]"
|
63
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronen Barzel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -169,14 +169,14 @@ dependencies:
|
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '3.
|
172
|
+
version: '3.4'
|
173
173
|
type: :development
|
174
174
|
prerelease: false
|
175
175
|
version_requirements: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: '3.
|
179
|
+
version: '3.4'
|
180
180
|
- !ruby/object:Gem::Dependency
|
181
181
|
name: rake
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,10 +267,14 @@ files:
|
|
267
267
|
- Rakefile
|
268
268
|
- TODO.md
|
269
269
|
- gemfiles/Gemfile.base
|
270
|
-
- gemfiles/activerecord-4.2/Gemfile.base
|
271
|
-
- gemfiles/activerecord-4.2/Gemfile.mysql2
|
272
|
-
- gemfiles/activerecord-4.2/Gemfile.postgresql
|
273
|
-
- gemfiles/activerecord-4.2/Gemfile.sqlite3
|
270
|
+
- gemfiles/activerecord-4.2.0/Gemfile.base
|
271
|
+
- gemfiles/activerecord-4.2.0/Gemfile.mysql2
|
272
|
+
- gemfiles/activerecord-4.2.0/Gemfile.postgresql
|
273
|
+
- gemfiles/activerecord-4.2.0/Gemfile.sqlite3
|
274
|
+
- gemfiles/activerecord-4.2.1/Gemfile.base
|
275
|
+
- gemfiles/activerecord-4.2.1/Gemfile.mysql2
|
276
|
+
- gemfiles/activerecord-4.2.1/Gemfile.postgresql
|
277
|
+
- gemfiles/activerecord-4.2.1/Gemfile.sqlite3
|
274
278
|
- lib/schema_plus.rb
|
275
279
|
- lib/schema_plus/db_default.rb
|
276
280
|
- lib/schema_plus/db_default/active_record/attribute.rb
|