From 4dc31cdb69964b99c952f39babb6b3f96dec34cd Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 4 Nov 2010 11:30:10 -0500 Subject: [PATCH 01/11] Store all databases connected to in hash. --- lib/sequel-rails/railtie.rb | 2 +- lib/sequel-rails/setup.rb | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/sequel-rails/railtie.rb b/lib/sequel-rails/railtie.rb index 802c2f5..9a1a244 100644 --- a/lib/sequel-rails/railtie.rb +++ b/lib/sequel-rails/railtie.rb @@ -48,7 +48,7 @@ class Railtie < Rails::Railtie end initializer "sequel.connect" do |app| - Rails::Sequel.setup(Rails.env) + Rails::Sequel.database(Rails.env) end # Run setup code after_initialize to make sure all config/initializers diff --git a/lib/sequel-rails/setup.rb b/lib/sequel-rails/setup.rb index 4907445..7222472 100644 --- a/lib/sequel-rails/setup.rb +++ b/lib/sequel-rails/setup.rb @@ -8,12 +8,15 @@ module Rails module Sequel - + @databases = {} + def self.setup(environment) - puts "[sequel] Setting up the #{environment.inspect} environment:" - - ::Sequel.connect({:logger => configuration.logger}.merge(::Rails::Sequel.configuration.environment_for(environment.to_s))) + config = ::Rails::Sequel.configuration.environment_for(environment.to_s) + ::Sequel.connect({:logger => configuration.logger}.merge(config)) + end + + def self.database(name) + @databases[name] ||= setup(name) end - end end From 363fbeb4093efd56b43e20b8ab5c613bb60d1249 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Fri, 5 Nov 2010 09:53:24 -0500 Subject: [PATCH 02/11] Update README.rdoc for multiple databases. --- README.rdoc | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/README.rdoc b/README.rdoc index 07cde0f..23f59c2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -49,6 +49,50 @@ Once you do that, you will see the following rake tasks among others. These are vendor/bin/rake db:setup # Create the database, load the schema, and initialize with the seed data ... +== Supporting Multiple Databases + +sequel-rails supports the use of more than one database per environment across your models. +Currently, additional databases can be entered at the top level of your database.yml: + + ... + development: + adapter: mysql + database: development + username: username + password: password + host: localhost + + test: + adapter: mysql + database: test + username: username + password: password + host: localhost + + production: + adapter: mysql + database: production + username: username + password: password + host: localhost + + extra: + adapter: mysql + database: extra + username: username + password: password + host: localhost + ... + +You can then set this database for a model using the following syntax: + + ... + class Foo < Sequel::Model(Rails::Sequel.database(:extra)) + + end + ... + +Databases are only connected to once are defined in a Sequel::Model. == Current Issues From fac1d340981bee44aa25aad7cb87a69c216b6518 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Fri, 5 Nov 2010 09:56:41 -0500 Subject: [PATCH 03/11] Cleaning up README.rdoc. --- README.rdoc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.rdoc b/README.rdoc index 23f59c2..30fda28 100644 --- a/README.rdoc +++ b/README.rdoc @@ -51,7 +51,7 @@ Once you do that, you will see the following rake tasks among others. These are == Supporting Multiple Databases -sequel-rails supports the use of more than one database per environment across your models. +Sequel and sequel-rails support the use of more than one database per environment across your models. Currently, additional databases can be entered at the top level of your database.yml: ... @@ -84,15 +84,13 @@ Currently, additional databases can be entered at the top level of your database host: localhost ... -You can then set this database for a model using the following syntax: +You can then set an extra database for a model using the following syntax: - ... class Foo < Sequel::Model(Rails::Sequel.database(:extra)) - + end - ... -Databases are only connected to once are defined in a Sequel::Model. +Databases are only connected to once they are defined for a Sequel::Model == Current Issues From 5f34d0a5066ba85183bfed22426737db0ad44962 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Fri, 28 Jan 2011 11:31:09 -0600 Subject: [PATCH 04/11] Update necessary railties to be required. --- README.rdoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rdoc b/README.rdoc index 30fda28..60823bd 100644 --- a/README.rdoc +++ b/README.rdoc @@ -11,18 +11,18 @@ Using sequel with rails3 requires a couple minor changes. First, add the following to your Gemfile: gem 'sequel-rails' - + ... be sure to run "bundle install" if needed! Secondly, you'll need to require "sequel-rails/railtie" in your config/application.rb file, and not require activerecord. The top of your config/application.rb will probably look something like: - + # require 'rails/all' - + # Instead of 'rails/all', require these: require "action_controller/railtie" - require "sequel-rails/railtie" require "action_mailer/railtie" - + require "rails/test_unit/railtie" + require "sequel-rails/railtie" After those changes, you should be good to go! @@ -87,7 +87,7 @@ Currently, additional databases can be entered at the top level of your database You can then set an extra database for a model using the following syntax: class Foo < Sequel::Model(Rails::Sequel.database(:extra)) - + end Databases are only connected to once they are defined for a Sequel::Model From 505535892adc8fe35c3ac9e82076957b05974849 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:04:46 -0500 Subject: [PATCH 05/11] Ignore Rubymine files. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 14ccdf0..e921121 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ vendor .bundle .rvmrc *.gem + +## Rubymine +.idea From 28252823a2ce19108e433d0924358a703f073860 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:51:18 -0500 Subject: [PATCH 06/11] Version bump to 0.1.6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9faa1b7..a192233 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.5 +0.1.6 \ No newline at end of file From 8a9ca945b72917d2968cd1e53c5bf17ea807fd73 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:51:26 -0500 Subject: [PATCH 07/11] Version bump to 0.1.7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a192233..a1e1395 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.6 \ No newline at end of file +0.1.7 \ No newline at end of file From 6c494928c9cc27d3bc410d8de430c3b3be1f4d13 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:51:35 -0500 Subject: [PATCH 08/11] Version bump to 0.1.8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a1e1395..84aa3a7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.7 \ No newline at end of file +0.1.8 \ No newline at end of file From 1ae7908d029c90715ac47e20e122e90a34fccf17 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:51:43 -0500 Subject: [PATCH 09/11] Version bump to 0.1.9 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 84aa3a7..82551ad 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.8 \ No newline at end of file +0.1.9 \ No newline at end of file From 95034ed9ff774f72fa790bf77660a33775ae8ae1 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 15:55:03 -0500 Subject: [PATCH 10/11] Update gemspec dependencies to not use a prerelease. --- Gemfile | 6 +- Rakefile | 6 +- sequel-rails.gemspec | 133 ++++++++++++++++++++++++------------------- 3 files changed, 82 insertions(+), 63 deletions(-) diff --git a/Gemfile b/Gemfile index cbf51f9..ba3bcc2 100644 --- a/Gemfile +++ b/Gemfile @@ -6,9 +6,9 @@ gem 'yard', '~> 0.5' git 'git://github.com/rails/rails.git' do - gem 'activesupport', '~> 3.0.0.beta3', :require => 'active_support' - gem 'actionpack', '~> 3.0.0.beta3', :require => 'action_pack' - gem 'railties', '~> 3.0.0.beta3', :require => 'rails' + gem 'activesupport', '~> 3.0.0', :require => 'active_support' + gem 'actionpack', '~> 3.0.0', :require => 'action_pack' + gem 'railties', '~> 3.0.0', :require => 'rails' end diff --git a/Rakefile b/Rakefile index 1fd9e3c..4de3013 100644 --- a/Rakefile +++ b/Rakefile @@ -16,9 +16,9 @@ begin gem.add_dependency 'sequel', '~> 3.13' - gem.add_dependency 'activesupport', '~> 3.0.0.rc' - gem.add_dependency 'actionpack', '~> 3.0.0.rc' - gem.add_dependency 'railties', '~> 3.0.0.rc' + gem.add_dependency 'activesupport', '~> 3.0.0' + gem.add_dependency 'actionpack', '~> 3.0.0' + gem.add_dependency 'railties', '~> 3.0.0' # gem.add_development_dependency 'yard', '~> 0.5' diff --git a/sequel-rails.gemspec b/sequel-rails.gemspec index aba0de9..6570cae 100644 --- a/sequel-rails.gemspec +++ b/sequel-rails.gemspec @@ -1,93 +1,112 @@ # Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{sequel-rails} - s.version = "0.1.7" + s.version = "0.1.9" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Brasten Sager (brasten)"] - s.date = %q{2010-08-11} + s.date = %q{2011-03-31} s.description = %q{Integrate Sequel with Rails 3} s.email = %q{brasten@gmail.com} s.extra_rdoc_files = [ + "CHANGELOG", "LICENSE", - "README.rdoc" + "README.rdoc" ] s.files = [ ".document", - ".gitignore", - "CHANGELOG", - "Gemfile", - "LICENSE", - "README.rdoc", - "Rakefile", - "VERSION", - "autotest/discover.rb", - "lib/generators/sequel.rb", - "lib/generators/sequel/migration/migration_generator.rb", - "lib/generators/sequel/migration/templates/migration.rb", - "lib/generators/sequel/model/model_generator.rb", - "lib/generators/sequel/model/templates/model.rb", - "lib/generators/sequel/observer/observer_generator.rb", - "lib/generators/sequel/observer/templates/observer.rb", - "lib/sequel-rails.rb", - "lib/sequel-rails/configuration.rb", - "lib/sequel-rails/migrations.rb", - "lib/sequel-rails/railtie.rb", - "lib/sequel-rails/railties/benchmarking_mixin.rb", - "lib/sequel-rails/railties/controller_runtime.rb", - "lib/sequel-rails/railties/database.rake", - "lib/sequel-rails/railties/i18n_support.rb", - "lib/sequel-rails/railties/log_subscriber.rb", - "lib/sequel-rails/runtime.rb", - "lib/sequel-rails/session_store.rb", - "lib/sequel-rails/setup.rb", - "lib/sequel-rails/storage.rb", - "sequel-rails.gemspec", - "spec/rcov.opts", - "spec/setup_spec.rb", - "spec/spec.opts", - "spec/spec_helper.rb", - "tasks/ci.rake", - "tasks/clean.rake", - "tasks/metrics.rake", - "tasks/spec.rake", - "tasks/yard.rake", - "tasks/yardstick.rake" + "CHANGELOG", + "Gemfile", + "LICENSE", + "README.rdoc", + "Rakefile", + "VERSION", + "autotest/discover.rb", + "lib/generators/sequel.rb", + "lib/generators/sequel/migration/migration_generator.rb", + "lib/generators/sequel/migration/templates/migration.rb", + "lib/generators/sequel/model/model_generator.rb", + "lib/generators/sequel/model/templates/model.rb", + "lib/generators/sequel/observer/observer_generator.rb", + "lib/generators/sequel/observer/templates/observer.rb", + "lib/sequel-rails.rb", + "lib/sequel-rails/configuration.rb", + "lib/sequel-rails/migrations.rb", + "lib/sequel-rails/railtie.rb", + "lib/sequel-rails/railties/benchmarking_mixin.rb", + "lib/sequel-rails/railties/controller_runtime.rb", + "lib/sequel-rails/railties/database.rake", + "lib/sequel-rails/railties/i18n_support.rb", + "lib/sequel-rails/railties/log_subscriber.rb", + "lib/sequel-rails/runtime.rb", + "lib/sequel-rails/session_store.rb", + "lib/sequel-rails/setup.rb", + "lib/sequel-rails/storage.rb", + "sequel-rails.gemspec", + "spec/rcov.opts", + "spec/setup_spec.rb", + "spec/spec.opts", + "spec/spec_helper.rb", + "tasks/ci.rake", + "tasks/clean.rake", + "tasks/metrics.rake", + "tasks/spec.rake", + "tasks/yard.rake", + "tasks/yardstick.rake" ] s.homepage = %q{http://github.com/brasten/sequel-rails} - s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.6} + s.rubygems_version = %q{1.4.2} s.summary = %q{Use Sequel with Rails 3} s.test_files = [ "spec/setup_spec.rb", - "spec/spec_helper.rb" + "spec/spec_helper.rb" ] if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, ["~> 0.8.7"]) + s.add_runtime_dependency(%q, ["~> 1.4"]) + s.add_runtime_dependency(%q, ["~> 0.5"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.11.0"]) s.add_runtime_dependency(%q, ["~> 3.13"]) - s.add_runtime_dependency(%q, ["~> 3.0.0.rc"]) - s.add_runtime_dependency(%q, ["~> 3.0.0.rc"]) - s.add_runtime_dependency(%q, ["~> 3.0.0.rc"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) + s.add_runtime_dependency(%q, ["~> 3.0.0"]) else + s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, ["~> 1.4"]) + s.add_dependency(%q, ["~> 0.5"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.11.0"]) s.add_dependency(%q, ["~> 3.13"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) end else + s.add_dependency(%q, ["~> 0.8.7"]) + s.add_dependency(%q, ["~> 1.4"]) + s.add_dependency(%q, ["~> 0.5"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.11.0"]) s.add_dependency(%q, ["~> 3.13"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) - s.add_dependency(%q, ["~> 3.0.0.rc"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) + s.add_dependency(%q, ["~> 3.0.0"]) end end From a3d9c21c65ded6fa088e8dcd54cbf9424f3f5f65 Mon Sep 17 00:00:00 2001 From: Brandon Hauff Date: Thu, 31 Mar 2011 16:09:57 -0500 Subject: [PATCH 11/11] Update sequel dependency. --- Gemfile | 2 +- sequel-rails.gemspec | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index ba3bcc2..f415295 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ git 'git://github.com/rails/rails.git' do end -gem 'sequel', '~> 3.11.0' +gem 'sequel', '~> 3.13' group :test do gem 'rspec' diff --git a/sequel-rails.gemspec b/sequel-rails.gemspec index 6570cae..fd30726 100644 --- a/sequel-rails.gemspec +++ b/sequel-rails.gemspec @@ -77,7 +77,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, ["~> 3.0.0"]) s.add_runtime_dependency(%q, ["~> 3.0.0"]) s.add_runtime_dependency(%q, ["~> 3.0.0"]) - s.add_runtime_dependency(%q, ["~> 3.11.0"]) + s.add_runtime_dependency(%q, ["~> 3.13"]) s.add_runtime_dependency(%q, ["~> 3.13"]) s.add_runtime_dependency(%q, ["~> 3.0.0"]) s.add_runtime_dependency(%q, ["~> 3.0.0"]) @@ -89,7 +89,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"]) - s.add_dependency(%q, ["~> 3.11.0"]) + s.add_dependency(%q, ["~> 3.13"]) s.add_dependency(%q, ["~> 3.13"]) s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"]) @@ -102,7 +102,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"]) - s.add_dependency(%q, ["~> 3.11.0"]) + s.add_dependency(%q, ["~> 3.13"]) s.add_dependency(%q, ["~> 3.13"]) s.add_dependency(%q, ["~> 3.0.0"]) s.add_dependency(%q, ["~> 3.0.0"])