secondbase 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +0 -8
 - data/Appraisals +1 -1
 - data/CHANGELOG.md +32 -1
 - data/README.md +2 -2
 - data/VERSION +1 -1
 - data/gemfiles/rails50.gemfile +1 -1
 - data/lib/second_base/databases.rake +9 -1
 - data/lib/second_base/railtie.rb +9 -0
 - data/test/cases/dbtask_test.rb +16 -0
 - data/test/test_helpers/dummy_app_helpers.rb +10 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c9047584f31fb714c9dac5282322e77e7fe2e4d7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7c83ddd5bc20695794e5545b98ebf04364effbc3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 5c700cbdea52c4a0a0488bb27f3649d752155157a7f941d9d37c80f343fb1c30ed8d315b67178d91ad6d234114c10fa80fe312185321f1edfbfc7e21b1a56148
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ca9ed021048b0f5fdb6404673702595b32423cdfc737c609f14a1a2fa1c0ee3b0f4aafaf7cc5baedf0f82cd98bd65d22a4ddf0f82ab2025ebfbd0bb82a1138c3
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            sudo: false
         
     | 
| 
       2 
2 
     | 
    
         
             
            cache: bundler
         
     | 
| 
       3 
3 
     | 
    
         
             
            rvm:
         
     | 
| 
       4 
     | 
    
         
            -
              - 2.0
         
     | 
| 
       5 
     | 
    
         
            -
              - 2.1
         
     | 
| 
       6 
4 
     | 
    
         
             
              - 2.2.2
         
     | 
| 
       7 
5 
     | 
    
         
             
              - 2.3.1
         
     | 
| 
       8 
6 
     | 
    
         
             
            gemfile:
         
     | 
| 
         @@ -16,9 +14,3 @@ install: 
     | 
|
| 
       16 
14 
     | 
    
         
             
              - bundle install
         
     | 
| 
       17 
15 
     | 
    
         
             
            script:
         
     | 
| 
       18 
16 
     | 
    
         
             
              - bundle exec rake test
         
     | 
| 
       19 
     | 
    
         
            -
            matrix:
         
     | 
| 
       20 
     | 
    
         
            -
              exclude:
         
     | 
| 
       21 
     | 
    
         
            -
                - rvm: 2.0
         
     | 
| 
       22 
     | 
    
         
            -
                  gemfile: gemfiles/rails50.gemfile
         
     | 
| 
       23 
     | 
    
         
            -
                - rvm: 2.1
         
     | 
| 
       24 
     | 
    
         
            -
                  gemfile: gemfiles/rails50.gemfile
         
     | 
    
        data/Appraisals
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,8 +1,39 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
1 
     | 
    
         
             
            # Change Log
         
     | 
| 
       3 
2 
     | 
    
         | 
| 
       4 
3 
     | 
    
         
             
            Please follow the format set down in http://keepachangelog.com
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
      
 5 
     | 
    
         
            +
            ## v2.1.2
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            * Tested w Rails 5.0 release.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            * Support for schema cache. Fixes #40
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            ## v2.1.1
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            * Test updates to track rails 5 rc2.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            ## v2.1.0
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            * Ability to disable the database task patching (thanks [@agrberg](https://github.com/agrberg))
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ## v2.0.0
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            * Rails 5 support.
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       6 
37 
     | 
    
         
             
            ## v1.0.1
         
     | 
| 
       7 
38 
     | 
    
         | 
| 
       8 
39 
     | 
    
         
             
            #### Fixed
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -51,6 +51,7 @@ This will not only create your base development database, but it will also creat 
     | 
|
| 
       51 
51 
     | 
    
         
             
            * db:migrate
         
     | 
| 
       52 
52 
     | 
    
         
             
            * db:test:purge
         
     | 
| 
       53 
53 
     | 
    
         
             
            * db:test:prepare
         
     | 
| 
      
 54 
     | 
    
         
            +
            * db:schema:cache:dump
         
     | 
| 
       54 
55 
     | 
    
         | 
| 
       55 
56 
     | 
    
         
             
            Not all base database tasks make sense to run a mirrored SecondBase task. These include tasks that move a single migration up/down, reporting on your database's current status/version, and others. These tasks have to be run explicitly and only operate on your SecondBase database. Each support any feature that their matching `:db` task has. For example, using `VERSION=123` to target a specific migration.
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
         @@ -113,7 +114,7 @@ require 'second_base/test_help' 
     | 
|
| 
       113 
114 
     | 
    
         | 
| 
       114 
115 
     | 
    
         
             
            #### Configurations
         
     | 
| 
       115 
116 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
            All SecondBase railtie settings are best done in a `config/ 
     | 
| 
      
 117 
     | 
    
         
            +
            All SecondBase railtie settings are best done in a `config/application.rb` file. We support the following configurations:
         
     | 
| 
       117 
118 
     | 
    
         | 
| 
       118 
119 
     | 
    
         
             
            ```ruby
         
     | 
| 
       119 
120 
     | 
    
         
             
            config.second_base.path        # Default: 'db/secondbase'
         
     | 
| 
         @@ -167,7 +168,6 @@ class ApplicationController < ActionController::Base 
     | 
|
| 
       167 
168 
     | 
    
         
             
            end
         
     | 
| 
       168 
169 
     | 
    
         
             
            ```
         
     | 
| 
       169 
170 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
171 
     | 
    
         
             
            ## Versions
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
            The current master branch is for Rails v4.0.0 and up and. We have older work in previous v1.0 releases which partial work for Rails 3.2 or lower. These old versions are feature incomplete and are not supported.
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            2.1. 
     | 
| 
      
 1 
     | 
    
         
            +
            2.1.2
         
     | 
    
        data/gemfiles/rails50.gemfile
    CHANGED
    
    
| 
         @@ -73,6 +73,14 @@ namespace :db do 
     | 
|
| 
       73 
73 
     | 
    
         
             
                    SecondBase.on_base { Rake::Task['db:schema:load'].execute }
         
     | 
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
      
 76 
     | 
    
         
            +
                  namespace :cache do
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                    task :dump do
         
     | 
| 
      
 79 
     | 
    
         
            +
                      SecondBase.on_base { Rake::Task['db:schema:cache:dump'].execute }
         
     | 
| 
      
 80 
     | 
    
         
            +
                    end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
       76 
84 
     | 
    
         
             
                end
         
     | 
| 
       77 
85 
     | 
    
         | 
| 
       78 
86 
     | 
    
         
             
                namespace :structure do
         
     | 
| 
         @@ -109,7 +117,7 @@ end 
     | 
|
| 
       109 
117 
     | 
    
         
             
            %w{
         
     | 
| 
       110 
118 
     | 
    
         
             
              create:all create drop:all purge:all purge
         
     | 
| 
       111 
119 
     | 
    
         
             
              migrate migrate:status abort_if_pending_migrations
         
     | 
| 
       112 
     | 
    
         
            -
              schema:load structure:load
         
     | 
| 
      
 120 
     | 
    
         
            +
              schema:load schema:cache:dump structure:load
         
     | 
| 
       113 
121 
     | 
    
         
             
              test:purge test:load_schema test:load_structure test:prepare
         
     | 
| 
       114 
122 
     | 
    
         
             
            }.each do |name|
         
     | 
| 
       115 
123 
     | 
    
         
             
              task = Rake::Task["db:#{name}"] rescue nil
         
     | 
    
        data/lib/second_base/railtie.rb
    CHANGED
    
    | 
         @@ -31,6 +31,15 @@ module SecondBase 
     | 
|
| 
       31 
31 
     | 
    
         
             
                  config.watchable_files.concat ["#{secondbase_dir}/schema.rb", "#{secondbase_dir}/structure.sql"]
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
      
 34 
     | 
    
         
            +
                initializer 'second_base.check_schema_cache_dump', after: 'active_record.check_schema_cache_dump' do |app|
         
     | 
| 
      
 35 
     | 
    
         
            +
                  use_cache  = config.active_record.use_schema_cache_dump
         
     | 
| 
      
 36 
     | 
    
         
            +
                  cache_file = app.root.join(config.second_base.path, 'schema_cache.dump')
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if use_cache && File.file?(cache_file)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    cache = Marshal.load File.binread(cache_file)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    SecondBase::Base.connection.schema_cache = cache
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       34 
43 
     | 
    
         
             
                def config_path
         
     | 
| 
       35 
44 
     | 
    
         
             
                  config.second_base.path
         
     | 
| 
       36 
45 
     | 
    
         
             
                end
         
     | 
    
        data/test/cases/dbtask_test.rb
    CHANGED
    
    | 
         @@ -176,6 +176,22 @@ class DbTaskTest < SecondBase::TestCase 
     | 
|
| 
       176 
176 
     | 
    
         
             
                assert_connection_tables SecondBase::Base, ['comments']
         
     | 
| 
       177 
177 
     | 
    
         
             
              end
         
     | 
| 
       178 
178 
     | 
    
         | 
| 
      
 179 
     | 
    
         
            +
              def test_db_test_schema_cache_dump
         
     | 
| 
      
 180 
     | 
    
         
            +
                run_db :create
         
     | 
| 
      
 181 
     | 
    
         
            +
                run_db :migrate
         
     | 
| 
      
 182 
     | 
    
         
            +
                assert_dummy_databases
         
     | 
| 
      
 183 
     | 
    
         
            +
                Dir.chdir(dummy_root) { `rake db:schema:cache:dump` }
         
     | 
| 
      
 184 
     | 
    
         
            +
                assert File.file?(dummy_schema_cache), 'dummy schema cache does not exist'
         
     | 
| 
      
 185 
     | 
    
         
            +
                assert File.file?(dummy_secondbase_schema_cache), 'dummy secondbase schema cache does not exist'
         
     | 
| 
      
 186 
     | 
    
         
            +
                cache1 = Marshal.load(File.binread(dummy_schema_cache))
         
     | 
| 
      
 187 
     | 
    
         
            +
                cache2 = Marshal.load(File.binread(dummy_secondbase_schema_cache))
         
     | 
| 
      
 188 
     | 
    
         
            +
                source_method = rails_50_up? ? :data_sources : :tables
         
     | 
| 
      
 189 
     | 
    
         
            +
                assert cache1.send(source_method, 'posts'),    'base should have posts table in cache'
         
     | 
| 
      
 190 
     | 
    
         
            +
                refute cache1.send(source_method, 'comments'), 'base should not have comments table in cache'
         
     | 
| 
      
 191 
     | 
    
         
            +
                refute cache2.send(source_method, 'posts'),    'secondbase should not have posts table in cache'
         
     | 
| 
      
 192 
     | 
    
         
            +
                assert cache2.send(source_method, 'comments'), 'secondbase should have comments table in cache'
         
     | 
| 
      
 193 
     | 
    
         
            +
              end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
       179 
195 
     | 
    
         
             
              def test_abort_if_pending
         
     | 
| 
       180 
196 
     | 
    
         
             
                run_db :create
         
     | 
| 
       181 
197 
     | 
    
         
             
                run_db :migrate
         
     | 
| 
         @@ -29,10 +29,18 @@ module SecondBase 
     | 
|
| 
       29 
29 
     | 
    
         
             
                  dummy_db.join 'schema.rb'
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
                def dummy_schema_cache
         
     | 
| 
      
 33 
     | 
    
         
            +
                  dummy_db.join 'schema_cache.dump'
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
       32 
36 
     | 
    
         
             
                def dummy_secondbase_schema
         
     | 
| 
       33 
37 
     | 
    
         
             
                  dummy_db.join('secondbase', 'schema.rb')
         
     | 
| 
       34 
38 
     | 
    
         
             
                end
         
     | 
| 
       35 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                def dummy_secondbase_schema_cache
         
     | 
| 
      
 41 
     | 
    
         
            +
                  dummy_db.join('secondbase', 'schema_cache.dump')
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       36 
44 
     | 
    
         
             
                def dummy_database_sqlite
         
     | 
| 
       37 
45 
     | 
    
         
             
                  Dir.chdir(dummy_db){ Dir['*.sqlite3'] }.first
         
     | 
| 
       38 
46 
     | 
    
         
             
                end
         
     | 
| 
         @@ -54,6 +62,8 @@ module SecondBase 
     | 
|
| 
       54 
62 
     | 
    
         
             
                def delete_dummy_files
         
     | 
| 
       55 
63 
     | 
    
         
             
                  FileUtils.rm_rf dummy_schema
         
     | 
| 
       56 
64 
     | 
    
         
             
                  FileUtils.rm_rf dummy_secondbase_schema
         
     | 
| 
      
 65 
     | 
    
         
            +
                  FileUtils.rm_rf dummy_schema_cache
         
     | 
| 
      
 66 
     | 
    
         
            +
                  FileUtils.rm_rf dummy_secondbase_schema_cache
         
     | 
| 
       57 
67 
     | 
    
         
             
                  Dir.chdir(dummy_db) { Dir['**/structure.sql'].each { |structure| FileUtils.rm_rf(structure) } }
         
     | 
| 
       58 
68 
     | 
    
         
             
                  Dir.chdir(dummy_db) { FileUtils.rm_rf(dummy_database_sqlite) } if dummy_database_sqlite
         
     | 
| 
       59 
69 
     | 
    
         
             
                  FileUtils.rm_rf(dummy_migration[:file]) if defined?(@dummy_migration) && @dummy_migration
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: secondbase
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 2.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Karle Durante
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2017-01-24 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       197 
197 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       198 
198 
     | 
    
         
             
            requirements: []
         
     | 
| 
       199 
199 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       200 
     | 
    
         
            -
            rubygems_version: 2.4 
     | 
| 
      
 200 
     | 
    
         
            +
            rubygems_version: 2.6.4
         
     | 
| 
       201 
201 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       202 
202 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       203 
203 
     | 
    
         
             
            summary: Seamless second database integration for Rails.
         
     |