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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61e2c68d4c34a1a67e9dd384a88b39a1c51ac28b
4
- data.tar.gz: 2d6b58497e571c08e38ce563a74f56b5d1f9a5d3
3
+ metadata.gz: 0c5aee9479eef0756986536130a26f38f23c4a87
4
+ data.tar.gz: 4447fc06494c1646f8587f11882751618fc9f4cd
5
5
  SHA512:
6
- metadata.gz: 70b083aec779efb9afebd741e24ef825d99f0c4dfdd89e416cd3cd4d61f38238a40541e8182dae1de155a96cb5abdd71082666024c145600b391dfc5169cbea5
7
- data.tar.gz: fa3810d8ba0c11444928631f3d285303c76f1b8bfe272c495cdf82bff2e84285253159d3e51a34c861f0d4adfed5e922fc67ef65eead4b682d83d6397600e97d
6
+ metadata.gz: 235927976009fd939faa6180f2465a12aa03db03263f310428c94e2d23bb3ba9c86e9343cc2dcdd4a12bead0ed058f9b84ce61d13e9ec06f1cdda719e768b5f5
7
+ data.tar.gz: fb6d3574efc491cdf8d4e344a0c554f051ee072fae6a3050ecdc5e32cb2021daec0acf8076f86d43aec0ccf3ae75c3558ef7a451142414886e6b5303512229d1
@@ -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
@@ -1,3 +1,3 @@
1
1
  eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
2
 
3
- gem "activerecord", "~> 4.2.0"
3
+ gem "activerecord", "4.2.0"
@@ -0,0 +1,3 @@
1
+ eval File.read File.expand_path('../../Gemfile.base', __FILE__)
2
+
3
+ gem "activerecord", "4.2.1"
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "mysql2"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "pg"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
@@ -0,0 +1,10 @@
1
+ require "pathname"
2
+ eval(Pathname.new(__FILE__).dirname.join("Gemfile.base").read, binding)
3
+
4
+ platform :ruby do
5
+ gem "sqlite3"
6
+ end
7
+
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcsqlite3-adapter', '>=1.3.0.beta2'
10
+ end
@@ -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
- foreign_keys << ::ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(self.name, AbstractAdapter.proper_table_name(to_table), options)
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
- options[:foreign_key] = false if is_reference
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
- args ||= {} if config.auto_create? and column_name =~ /_id$/
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
- env.sql.body = ([env.sql.body] + env.table_definition.foreign_keys.map(&:to_sql)).join(', ')
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
@@ -1,3 +1,3 @@
1
1
  module SchemaPlus
2
- VERSION = "2.0.0.pre9"
2
+ VERSION = "2.0.0.pre10"
3
3
  end
@@ -1,7 +1,8 @@
1
1
  ruby:
2
2
  - 2.1.5
3
3
  activerecord:
4
- - 4.2
4
+ - 4.2.0
5
+ - 4.2.1
5
6
  db:
6
7
  - mysql2
7
8
  - sqlite3
@@ -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.1"
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"
@@ -59,5 +59,5 @@ def remove_all_models
59
59
  end
60
60
  end
61
61
 
62
- SimpleCov.command_name "[ruby #{RUBY_VERSION} - ActiveRecord #{::ActiveRecord::VERSION::STRING} - #{ActiveRecord::Base.connection.adapter_name}]"
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.pre9
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-13 00:00:00.000000000 Z
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.1'
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.1'
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