diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 17:30:40 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 17:30:40 +0000 |
commit | d25fe84a01bd026945f1e86b1f651094f66151b2 (patch) | |
tree | 7ec26374d38adbe122c74d8a725e4c08802b3e05 /railties/lib/tasks | |
parent | e14acca8a83f14d40d29cdd3418d626ca1043c07 (diff) | |
download | rails-d25fe84a01bd026945f1e86b1f651094f66151b2.tar.gz rails-d25fe84a01bd026945f1e86b1f651094f66151b2.tar.bz2 rails-d25fe84a01bd026945f1e86b1f651094f66151b2.zip |
Added create_session_table, drop_session_table, and purge_session_table as rake tasks for databases that supports migrations (MySQL, PostgreSQL, SQLite) to get a table for use with CGI::Session::ActiveRecordStore. Added configuration of session options through config.session_options in Rails::Configuration
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2219 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/tasks')
-rw-r--r-- | railties/lib/tasks/databases.rake | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index e7ae234b53..077bfe296a 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -37,7 +37,7 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do ActiveRecord::Base.connection.execute(ddl) end else - raise "Unknown database adapter '#{abcs["test"]["adapter"]}'" + raise "Task not supported by '#{abcs["test"]["adapter"]}'" end end @@ -59,7 +59,7 @@ task :db_structure_dump => :environment do `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r` `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` else - raise "Unknown database adapter '#{abcs["test"]["adapter"]}'" + raise "Task not supported by '#{abcs["test"]["adapter"]}'" end if ActiveRecord::Base.connection.supports_migrations? @@ -92,6 +92,30 @@ task :purge_test_database => :environment do ActiveRecord::Base.connection.execute(ddl) end else - raise "Unknown database adapter '#{abcs["test"]["adapter"]}'" + raise "Task not supported by '#{abcs["test"]["adapter"]}'" end +end + +desc "Creates a sessions table for use with CGI::Session::ActiveRecordStore" +task :create_session_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| + t.column :sessid, :string + t.column :data, :text + t.column :updated_at, :datetime + end + + ActiveRecord::Base.connection.add_index :sessions, :sessid +end + +desc "Drop the sessions table" +task :drop_session_table => :environment do + raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? + + ActiveRecord::Base.connection.drop_table :sessions +end + +desc "Drop and recreate the session table (much faster than 'DELETE * FROM sessions')" +task :purge_session_table => [ :drop_session_table, :create_session_table ] do end
\ No newline at end of file |