aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Molina <marcel@vernix.org>2005-12-18 20:20:49 +0000
committerMarcel Molina <marcel@vernix.org>2005-12-18 20:20:49 +0000
commit56234bee14ad5219d4d1720a6a3532f684ed3a0d (patch)
tree2f00c7c05b64e5d3d859868811baa71e939db4bc
parent39766a9b4cde8f75a5837442b876e1e11a16ece4 (diff)
downloadrails-56234bee14ad5219d4d1720a6a3532f684ed3a0d.tar.gz
rails-56234bee14ad5219d4d1720a6a3532f684ed3a0d.tar.bz2
rails-56234bee14ad5219d4d1720a6a3532f684ed3a0d.zip
Honor ActiveRecord::Base.pluralize_table_names when creating and destroying session store table. Closes #3204.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3317 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/tasks/databases.rake10
2 files changed, 9 insertions, 3 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 0993ff826b..dcd5ef11c7 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Honor ActiveRecord::Base.pluralize_table_names when creating and destroying session store table. #3204. [rails@bencurtis.com, Marcel Molina Jr.]
+
* Update to script.aculo.us 1.5.0 final (equals 1.5.0_rc6) [Thomas Fuchs]
* Update to Prototype 1.4.0 final [Sam Stephenson]
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 83140b1164..1768f0a41a 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -128,6 +128,10 @@ def prepare_test_database_task
:ruby => :clone_schema_to_test}[ActiveRecord::Base.schema_format]
end
+def session_table_name
+ ActiveRecord::Base.pluralize_table_names ? :sessions : :session
+end
+
desc 'Prepare the test database and load the schema'
task :prepare_test_database => :environment do
Rake::Task[prepare_test_database_task].invoke
@@ -137,20 +141,20 @@ desc "Creates a sessions table for use with CGI::Session::ActiveRecordStore"
task :create_sessions_table => :environment do
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
- ActiveRecord::Base.connection.create_table :sessions do |t|
+ ActiveRecord::Base.connection.create_table session_table_name do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
- ActiveRecord::Base.connection.add_index :sessions, :session_id
+ ActiveRecord::Base.connection.add_index session_table_name, :session_id
end
desc "Drop the sessions table"
task :drop_sessions_table => :environment do
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
- ActiveRecord::Base.connection.drop_table :sessions
+ ActiveRecord::Base.connection.drop_table session_table_name
end
desc "Drop and recreate the session table (much faster than 'DELETE * FROM sessions')"