db-charmer 1.6.0 → 1.6.1
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.
- data/CHANGES +8 -0
- data/README.rdoc +10 -3
- data/VERSION +1 -1
- data/db-charmer.gemspec +1 -1
- data/lib/db_charmer.rb +0 -7
- data/lib/db_charmer/multi_db_migrations.rb +2 -1
- data/lib/db_charmer/multi_db_proxy.rb +1 -1
- metadata +2 -2
    
        data/CHANGES
    CHANGED
    
    | @@ -1,3 +1,11 @@ | |
| 1 | 
            +
            1.6.1 (2010-03-31):
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Breaking change from now on all connection-switching methods (both in migrations and in
         | 
| 4 | 
            +
            models) are controlled by a single option DbCharmer.connections_should_exist. This
         | 
| 5 | 
            +
            option is false by default in all non-production environments. Check out README for
         | 
| 6 | 
            +
            more details.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ----------------------------------------------------------------------------------------
         | 
| 1 9 | 
             
            1.6.0 (2010-03-31):
         | 
| 2 10 |  | 
| 3 11 | 
             
            The major (and arguably the only noticeable) change in this version is our simple database
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -132,7 +132,7 @@ connection from your database.yml files and rails would create the tables in you | |
| 132 132 | 
             
            but in production you'd specify it and get the table created on a separate server and/or in a
         | 
| 133 133 | 
             
            separate database.
         | 
| 134 134 |  | 
| 135 | 
            -
            This behaviour is controlled by the <tt>DbCharmer. | 
| 135 | 
            +
            This behaviour is controlled by the <tt>DbCharmer.connections_should_exist</tt>
         | 
| 136 136 | 
             
            configuration attribute which could be set from a rails initializer.
         | 
| 137 137 |  | 
| 138 138 |  | 
| @@ -218,6 +218,13 @@ as the +switch_connection_to+ method does. Example: | |
| 218 218 | 
             
              Comment.on_db(:olap).count
         | 
| 219 219 | 
             
              Post.on_db(:foo).find(:first)
         | 
| 220 220 |  | 
| 221 | 
            +
            By default in development and test environments you could use non-existing connections in your
         | 
| 222 | 
            +
            <tt>on_db</tt> calls and rails would send all your queries to a single default database. In
         | 
| 223 | 
            +
            production <tt>on_db</tt> won't accept non-existing names.
         | 
| 224 | 
            +
             | 
| 225 | 
            +
            This behaviour is controlled by the <tt>DbCharmer.connections_should_exist</tt>
         | 
| 226 | 
            +
            configuration attribute which could be set from a rails initializer.
         | 
| 227 | 
            +
             | 
| 221 228 |  | 
| 222 229 | 
             
            === Associations Connection Management
         | 
| 223 230 |  | 
| @@ -361,8 +368,8 @@ of sharded connections initizlization calls: | |
| 361 368 | 
             
              }
         | 
| 362 369 |  | 
| 363 370 | 
             
              DbCharmer::Sharding.register_connection(
         | 
| 364 | 
            -
                :name => : | 
| 365 | 
            -
                :method => : | 
| 371 | 
            +
                :name => :users,
         | 
| 372 | 
            +
                :method => :hash_map,
         | 
| 366 373 | 
             
                :map => SHARDING_MAP
         | 
| 367 374 | 
             
              )
         | 
| 368 375 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.6. | 
| 1 | 
            +
            1.6.1
         | 
    
        data/db-charmer.gemspec
    CHANGED
    
    
    
        data/lib/db_charmer.rb
    CHANGED
    
    | @@ -1,11 +1,4 @@ | |
| 1 1 | 
             
            module DbCharmer
         | 
| 2 | 
            -
              @@migration_connections_should_exist = Rails.env.production?
         | 
| 3 | 
            -
              mattr_accessor :migration_connections_should_exist
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              def self.migration_connections_should_exist?
         | 
| 6 | 
            -
                !! migration_connections_should_exist
         | 
| 7 | 
            -
              end
         | 
| 8 | 
            -
             | 
| 9 2 | 
             
              @@connections_should_exist = Rails.env.production?
         | 
| 10 3 | 
             
              mattr_accessor :connections_should_exist
         | 
| 11 4 |  | 
| @@ -15,7 +15,8 @@ module DbCharmer | |
| 15 15 | 
             
                  announce "Switching connection to #{name}"
         | 
| 16 16 | 
             
                  # Switch connection
         | 
| 17 17 | 
             
                  old_proxy = ActiveRecord::Base.db_charmer_connection_proxy
         | 
| 18 | 
            -
                   | 
| 18 | 
            +
                  db_name = nil if db_name == :default
         | 
| 19 | 
            +
                  ActiveRecord::Base.switch_connection_to(db_name, DbCharmer.connections_should_exist?)
         | 
| 19 20 | 
             
                  # Yield the block
         | 
| 20 21 | 
             
                  yield
         | 
| 21 22 | 
             
                ensure
         | 
| @@ -32,7 +32,7 @@ module DbCharmer | |
| 32 32 | 
             
                    begin
         | 
| 33 33 | 
             
                      self.db_charmer_connection_level += 1
         | 
| 34 34 | 
             
                      old_proxy = db_charmer_connection_proxy
         | 
| 35 | 
            -
                      switch_connection_to(con, DbCharmer. | 
| 35 | 
            +
                      switch_connection_to(con, DbCharmer.connections_should_exist?)
         | 
| 36 36 | 
             
                      yield(proxy_target)
         | 
| 37 37 | 
             
                    ensure
         | 
| 38 38 | 
             
                      switch_connection_to(old_proxy)
         |