diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-20 05:45:22 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-20 05:45:22 +0000 |
commit | 30c42b21b32132e53f5ec9129f042a797e4956cd (patch) | |
tree | bf2af633bc8fb2fa18410da931face8c9ee473f8 /railties | |
parent | 6d7335752ac51a959ce2ad203e74665d8f768956 (diff) | |
download | rails-30c42b21b32132e53f5ec9129f042a797e4956cd.tar.gz rails-30c42b21b32132e53f5ec9129f042a797e4956cd.tar.bz2 rails-30c42b21b32132e53f5ec9129f042a797e4956cd.zip |
Replaced old session rake tasks with db:sessions:create to generate a migration, and db:sessions:clear to remove sessions. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3995 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/tasks/databases.rake | 21 |
2 files changed, 8 insertions, 15 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index bc27d2692e..ed2562e136 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Replaced old session rake tasks with db:sessions:create to generate a migration, and db:sessions:clear to remove sessions. [Rick Olson] + * Reject Ruby 1.8.3 when loading Rails; extract version checking code. [Chad Fowler] * Remove explicit loading of RailsInfo and RailsInfoController. [Nicholas Seckar] diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 886db456f0..4ae88ac7ce 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -143,24 +143,15 @@ namespace :db do desc "Creates a sessions table for use with CGI::Session::ActiveRecordStore" task :create => :environment do raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? - - 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(session_table_name, :session_id) + require 'rails_generator' + require 'rails_generator/scripts/generate' + Rails::Generator::Scripts::Generate.new.run(["session_migration", ENV["MIGRATION"] || "AddSessionTable"]) end - desc "Drop the sessions table" - task :drop => :environment do + desc "Clear the sessions table" + task :clear => :environment do raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? - ActiveRecord::Base.connection.drop_table(session_table_name) - end - - desc "Drop and recreate the session table (much faster than 'DELETE * FROM sessions')" - task :recreate => [ "db:sessions:drop", "db:sessions:create" ] do + ActiveRecord::Base.connection.execute "DELETE FROM sessions" end end end |