dbview_cti 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +1 -1
  5. data/dbview_cti.gemspec +3 -1
  6. data/lib/db_view_cti/connection_adapters/schema_statements.rb +6 -2
  7. data/lib/db_view_cti/version.rb +1 -1
  8. data/spec/dummy-rails-3/db/migrate/20130711214909_create_vehicles.rb +3 -1
  9. data/spec/dummy-rails-3/db/migrate/20130713133605_create_motor_vehicles.rb +3 -1
  10. data/spec/dummy-rails-3/db/migrate/20130713133705_create_cars.rb +3 -1
  11. data/spec/dummy-rails-3/db/migrate/20130713153631_create_motor_cycles.rb +3 -1
  12. data/spec/dummy-rails-3/db/migrate/20130816022112_create_categories.rb +3 -1
  13. data/spec/dummy-rails-3/db/migrate/20130816022212_create_space_ships.rb +3 -1
  14. data/spec/dummy-rails-3/db/migrate/20130817014120_create_space_shuttles.rb +3 -1
  15. data/spec/dummy-rails-3/db/migrate/20130817024220_create_rocket_engines.rb +3 -1
  16. data/spec/dummy-rails-3/db/migrate/20130819040414_add_reliability_to_space_ships.rb +3 -1
  17. data/spec/dummy-rails-3/db/migrate/20131021211442_create_launches.rb +3 -1
  18. data/spec/dummy-rails-3/db/migrate/20131022010731_create_captains.rb +3 -1
  19. data/spec/dummy-rails-3/db/migrate/20131022020536_create_astronauts.rb +3 -1
  20. data/spec/dummy-rails-3/db/migrate/20131022020655_create_habtm_join_table.rb +3 -1
  21. data/spec/dummy-rails-3/db/migrate/20131022030659_create_experiments.rb +3 -1
  22. data/spec/dummy-rails-3/db/migrate/20131022030720_create_experiment_space_ship_performances.rb +3 -1
  23. data/spec/dummy-rails-3/db/migrate/20140408013710_check_view_exists.rb +3 -1
  24. data/spec/dummy-rails-3/db/migrate/20140411001620_add_upgraded_from_to_space_shuttles.rb +8 -2
  25. data/spec/dummy-rails-3/db/migrate/20140425182847_add_field_to_base_class.rb +3 -1
  26. data/spec/dummy-rails-3/db/migrate/migration_helper.rb +15 -0
  27. data/spec/dummy-rails-3/spec +1 -0
  28. data/spec/dummy-rails-4/app/models +1 -0
  29. data/spec/dummy-rails-4/config/database.yml +1 -0
  30. data/spec/dummy-rails-4/config/initializers/dbview_cti.rb +1 -0
  31. data/spec/dummy-rails-4/db/migrate +1 -0
  32. data/spec/dummy-rails-4/spec +1 -0
  33. data/spec/dummy-rails-5/app/models +1 -0
  34. data/spec/dummy-rails-5/db/migrate +1 -0
  35. metadata +10 -17
  36. data/spec/dummy-rails-4/config/database.yml +0 -37
  37. data/spec/dummy-rails-4/config/initializers/dbview_cti.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0b196d1516b1134fb4b2fb7c9cad12fb73d3ada
4
- data.tar.gz: 982271c1f983f11cb540917dc5d7977a690ffb84
3
+ metadata.gz: 7336700b3f30a53a54fa7e7c6e9cb9a68cad650b
4
+ data.tar.gz: 26f259b954a16441285911e82457f733f735afa4
5
5
  SHA512:
6
- metadata.gz: 9d0e9e6d3a8db60cc3b73105a69087f5834da2379119e4e9d66fcc94ad9d8ab740ccaf584be4e21ea0d33be4046beb084657a348e65647f87bd6e29174d35cb0
7
- data.tar.gz: eae2b3da9a8c6f9150d8c6ed29bb6a04141a0390207aec34a88f0192bcfbaabc2da6685e3df9cc7b246e18dee86a9e76306b34b2394fa4d01186e7b1382b1bbb
6
+ metadata.gz: 2d29f00ee7190def8971c8f9cf74793beac431378eec9baec22e1a15f32407a6c6ff4b8279f8996f93406253570367a1388be494e76362908b2ee75bf7cb37ec
7
+ data.tar.gz: 6ee75762da5263b42eb4a644f4c97bc1fee9980484b601bca1ff4764f4c614a394ca9a3e8202cd5dbd52371ca714452c6cb52eb7757ed3af6a212f2baee42d52
data/.travis.yml CHANGED
@@ -8,6 +8,7 @@ env:
8
8
  - "RAILS_VERSION=4.1.0"
9
9
  - "RAILS_VERSION=4.2.0"
10
10
  - "RAILS_VERSION=5.0.0"
11
+ - "RAILS_VERSION=5.1.0"
11
12
  script: bundle exec rspec spec/models
12
13
  before_script:
13
14
  - psql -c "CREATE USER cti WITH ENCRYPTED PASSWORD 'cti';" -U postgres
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.3 (30/04/2017)
2
+
3
+ * Added support for Rails 5.1.
4
+
1
5
  ## 0.2.2 (15/09/2016)
2
6
 
3
7
  * Fix deprecation messages that appeared when using Rails 5.
data/README.md CHANGED
@@ -5,7 +5,7 @@ This gem implements [Class Table Inheritance](http://martinfowler.com/eaaCatalog
5
5
  for Rails, as an alternative to Single Table Inheritance (STI). The implementation is based on database views.
6
6
  It allows you to combine polymorphism with database foreign key constraints.
7
7
 
8
- Currently, only PostgreSQL (version >= 9.1) is supported. The gem supports Rails 3.2, 4.0, 4.1, 4.2 and 5.0 apps running on
8
+ Currently, only PostgreSQL (version >= 9.1) is supported. The gem supports Rails 3.2, 4.0, 4.1, 4.2, 5.0 and 5.1 apps running on
9
9
  MRI (>= 1.9.3), Rubinius and JRuby in 1.9 mode.
10
10
 
11
11
  ## Installation
data/dbview_cti.gemspec CHANGED
@@ -20,5 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency "rails", ">= 3.2.0"
21
21
 
22
22
  s.add_development_dependency "rspec-rails", "~> 3.5"
23
- s.add_development_dependency "foreigner"
23
+ if ENV["RAILS_VERSION"] && ENV["RAILS_VERSION"][0].to_i < 5
24
+ s.add_development_dependency "foreigner"
25
+ end
24
26
  end
@@ -53,8 +53,12 @@ module DBViewCTI
53
53
  # any column changes are reflected in the real table cache, but not in the
54
54
  # view cache, so we have to make sure it is cleared
55
55
  klass = class_name.constantize
56
- klass.connection.schema_cache.clear_table_cache!(klass.table_name)
57
- klass.reset_column_information
56
+ if Rails::VERSION::MAJOR >= 5
57
+ klass.connection.schema_cache.clear_data_source_cache!(klass.table_name)
58
+ else
59
+ klass.connection.schema_cache.clear_table_cache!(klass.table_name)
60
+ end
61
+ klass.reset_column_information
58
62
  end
59
63
 
60
64
  end
@@ -1,3 +1,3 @@
1
1
  module DBViewCTI
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -1,4 +1,6 @@
1
- class CreateVehicles < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateVehicles < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :vehicles do |t|
4
6
  t.string :name
@@ -1,4 +1,6 @@
1
- class CreateMotorVehicles < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateMotorVehicles < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :motor_vehicles do |t|
4
6
  t.references :vehicle
@@ -1,4 +1,6 @@
1
- class CreateCars < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateCars < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :cars do |t|
4
6
  t.references :motor_vehicle
@@ -1,4 +1,6 @@
1
- class CreateMotorCycles < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateMotorCycles < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :motor_cycles do |t|
4
6
  t.references :motor_vehicle
@@ -1,4 +1,6 @@
1
- class CreateCategories < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateCategories < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :categories do |t|
4
6
  t.string :name
@@ -1,4 +1,6 @@
1
- class CreateSpaceShips < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateSpaceShips < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :space_ships do |t|
4
6
  t.references :vehicle
@@ -1,4 +1,6 @@
1
- class CreateSpaceShuttles < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateSpaceShuttles < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :space_shuttles do |t|
4
6
  t.references :space_ship
@@ -1,4 +1,6 @@
1
- class CreateRocketEngines < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateRocketEngines < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :rocket_engines do |t|
4
6
  t.references :space_ship
@@ -1,4 +1,6 @@
1
- class AddReliabilityToSpaceShips < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class AddReliabilityToSpaceShips < MigrationHelper.migration_base_class
2
4
  def up
3
5
  cti_recreate_views_after_change_to('SpaceShip') do
4
6
  add_column(:space_ships, :reliability, :integer)
@@ -1,4 +1,6 @@
1
- class CreateLaunches < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateLaunches < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :launches do |t|
4
6
  t.references :space_ship
@@ -1,4 +1,6 @@
1
- class CreateCaptains < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateCaptains < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :captains do |t|
4
6
  t.references :space_ship
@@ -1,4 +1,6 @@
1
- class CreateAstronauts < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateAstronauts < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :astronauts do |t|
4
6
  t.string :name
@@ -1,4 +1,6 @@
1
- class CreateHabtmJoinTable < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateHabtmJoinTable < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :astronauts_space_ships, id: false do |t|
4
6
  t.integer :astronaut_id
@@ -1,4 +1,6 @@
1
- class CreateExperiments < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateExperiments < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :experiments do |t|
4
6
  t.string :name
@@ -1,4 +1,6 @@
1
- class CreateExperimentSpaceShipPerformances < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CreateExperimentSpaceShipPerformances < MigrationHelper.migration_base_class
2
4
  def change
3
5
  create_table :experiment_space_ship_performances do |t|
4
6
  t.references :experiment
@@ -1,4 +1,6 @@
1
- class CheckViewExists < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class CheckViewExists < MigrationHelper.migration_base_class
2
4
  def up
3
5
  raise 'View should exist!' if !cti_view_exists?('Car')
4
6
  end
@@ -1,4 +1,6 @@
1
- class AddUpgradedFromToSpaceShuttles < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class AddUpgradedFromToSpaceShuttles < MigrationHelper.migration_base_class
2
4
  def up
3
5
  cti_recreate_views_after_change_to('SpaceShuttle') do
4
6
  add_column(:space_shuttles, :upgraded_from_id, :integer)
@@ -7,9 +9,13 @@ class AddUpgradedFromToSpaceShuttles < ActiveRecord::Migration
7
9
  end
8
10
 
9
11
  def down
12
+ if Rails::VERSION::MAJOR >= 5
13
+ remove_foreign_key :space_shuttles, :column => 'upgraded_from_id'
14
+ else
15
+ remove_foreign_key :space_shuttles, :space_ships, :column => 'upgraded_from_id'
16
+ end
10
17
  cti_recreate_views_after_change_to('SpaceShuttle') do
11
18
  remove_column(:space_shuttles, :upgraded_from_id)
12
19
  end
13
- remove_foreign_key :space_shuttles, :space_ships, :column => 'upgraded_from_id'
14
20
  end
15
21
  end
@@ -1,4 +1,6 @@
1
- class AddFieldToBaseClass < ActiveRecord::Migration
1
+ require_relative './migration_helper'
2
+
3
+ class AddFieldToBaseClass < MigrationHelper.migration_base_class
2
4
  def up
3
5
  # this makes cti_recreate_views_after_change_to also works for the base class
4
6
  cti_recreate_views_after_change_to('Vehicle') do
@@ -0,0 +1,15 @@
1
+ module MigrationHelper
2
+
3
+ def self.migration_base_class
4
+ klass = ActiveRecord::Migration
5
+
6
+ if Rails::VERSION::MAJOR >= 5
7
+ if Rails::VERSION::MAJOR > 5 || Rails::VERSION::MINOR >= 1
8
+ klass = ActiveRecord::Migration[4.2]
9
+ end
10
+ end
11
+
12
+ klass
13
+ end
14
+
15
+ end
@@ -0,0 +1 @@
1
+ spec/dummy-rails-3/../../spec
@@ -0,0 +1 @@
1
+ spec/dummy-rails-4/app/../../dummy-rails-3/app/models
@@ -0,0 +1 @@
1
+ spec/dummy-rails-4/config/../../dummy-rails-3/config/database.yml
@@ -0,0 +1 @@
1
+ spec/dummy-rails-4/config/initializers/../../../dummy-rails-3/config/initializers/dbview_cti.rb
@@ -0,0 +1 @@
1
+ spec/dummy-rails-4/db/../../dummy-rails-3/db/migrate
@@ -0,0 +1 @@
1
+ spec/dummy-rails-4/../../spec
@@ -0,0 +1 @@
1
+ spec/dummy-rails-5/app/../../dummy-rails-3/app/models
@@ -0,0 +1 @@
1
+ spec/dummy-rails-5/db/../../dummy-rails-3/db/migrate
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbview_cti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michaël Van Damme
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2017-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.5'
41
- - !ruby/object:Gem::Dependency
42
- name: foreigner
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  description: This gem implements Class Table Inheritance (CTI) for Rails using database
56
42
  views.
57
43
  email:
@@ -150,6 +136,7 @@ files:
150
136
  - spec/dummy-rails-3/db/migrate/20140408013710_check_view_exists.rb
151
137
  - spec/dummy-rails-3/db/migrate/20140411001620_add_upgraded_from_to_space_shuttles.rb
152
138
  - spec/dummy-rails-3/db/migrate/20140425182847_add_field_to_base_class.rb
139
+ - spec/dummy-rails-3/db/migrate/migration_helper.rb
153
140
  - spec/dummy-rails-3/db/schema.rb
154
141
  - spec/dummy-rails-3/lib/assets/.gitkeep
155
142
  - spec/dummy-rails-3/log/.gitkeep
@@ -158,6 +145,7 @@ files:
158
145
  - spec/dummy-rails-3/public/500.html
159
146
  - spec/dummy-rails-3/public/favicon.ico
160
147
  - spec/dummy-rails-3/script/rails
148
+ - spec/dummy-rails-3/spec
161
149
  - spec/dummy-rails-4/.rspec
162
150
  - spec/dummy-rails-4/Rakefile
163
151
  - spec/dummy-rails-4/app/assets/images/.keep
@@ -167,6 +155,7 @@ files:
167
155
  - spec/dummy-rails-4/app/controllers/concerns/.keep
168
156
  - spec/dummy-rails-4/app/helpers/application_helper.rb
169
157
  - spec/dummy-rails-4/app/mailers/.keep
158
+ - spec/dummy-rails-4/app/models
170
159
  - spec/dummy-rails-4/app/views/layouts/application.html.erb
171
160
  - spec/dummy-rails-4/bin/bundle
172
161
  - spec/dummy-rails-4/bin/rails
@@ -189,6 +178,7 @@ files:
189
178
  - spec/dummy-rails-4/config/initializers/wrap_parameters.rb
190
179
  - spec/dummy-rails-4/config/locales/en.yml
191
180
  - spec/dummy-rails-4/config/routes.rb
181
+ - spec/dummy-rails-4/db/migrate
192
182
  - spec/dummy-rails-4/db/schema.rb
193
183
  - spec/dummy-rails-4/lib/assets/.keep
194
184
  - spec/dummy-rails-4/log/.keep
@@ -196,6 +186,7 @@ files:
196
186
  - spec/dummy-rails-4/public/422.html
197
187
  - spec/dummy-rails-4/public/500.html
198
188
  - spec/dummy-rails-4/public/favicon.ico
189
+ - spec/dummy-rails-4/spec
199
190
  - spec/dummy-rails-5/Rakefile
200
191
  - spec/dummy-rails-5/app/assets/config/manifest.js
201
192
  - spec/dummy-rails-5/app/assets/images/.keep
@@ -210,6 +201,7 @@ files:
210
201
  - spec/dummy-rails-5/app/helpers/application_helper.rb
211
202
  - spec/dummy-rails-5/app/jobs/application_job.rb
212
203
  - spec/dummy-rails-5/app/mailers/application_mailer.rb
204
+ - spec/dummy-rails-5/app/models
213
205
  - spec/dummy-rails-5/app/models.original/application_record.rb
214
206
  - spec/dummy-rails-5/app/models.original/concerns/.keep
215
207
  - spec/dummy-rails-5/app/views/layouts/application.html.erb
@@ -245,6 +237,7 @@ files:
245
237
  - spec/dummy-rails-5/config/routes.rb
246
238
  - spec/dummy-rails-5/config/secrets.yml
247
239
  - spec/dummy-rails-5/config/spring.rb
240
+ - spec/dummy-rails-5/db/migrate
248
241
  - spec/dummy-rails-5/lib/assets/.keep
249
242
  - spec/dummy-rails-5/log/.keep
250
243
  - spec/dummy-rails-5/public/404.html
@@ -278,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
271
  version: '0'
279
272
  requirements: []
280
273
  rubyforge_project:
281
- rubygems_version: 2.4.8
274
+ rubygems_version: 2.6.11
282
275
  signing_key:
283
276
  specification_version: 4
284
277
  summary: Class Table Inheritance (CTI) for Rails.
@@ -1,37 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- #development:
7
- # adapter: sqlite3
8
- # database: db/development.sqlite3
9
- # pool: 5
10
- # timeout: 5000
11
-
12
- development:
13
- adapter: postgresql
14
- encoding: utf8
15
- pool: 5
16
- database: dbview_cti
17
- timeout: 5000
18
- username: cti
19
- password: cti
20
-
21
- # Warning: The database defined as "test" will be erased and
22
- # re-generated from your development database when you run "rake".
23
- # Do not set this db to the same as development or production.
24
- test:
25
- adapter: postgresql
26
- encoding: utf8
27
- pool: 5
28
- database: dbview_cti_test
29
- timeout: 5000
30
- username: cti
31
- password: cti
32
-
33
- production:
34
- adapter: sqlite3
35
- database: db/production.sqlite3
36
- pool: 5
37
- timeout: 5000
@@ -1,8 +0,0 @@
1
- # For dbview_cti, it is important that all classes are loaded, otherwise
2
- # methods like specialize return incorrect results.
3
- # We can force Rails to load all classes in the CTI hierarchy by loading
4
- # the leaf classes
5
- Car
6
- MotorCycle
7
- SpaceShuttle
8
-