This project is archived and is in readonly mode.
db:sessions:clear to respect legacy table names
Reported by felipekaufmann | June 2nd, 2009 @ 06:40 PM | in 3.x
rake db:sessions:clear has the table name for the sessions table hardcoded. Since the sessions table name is configurable trough:
ActiveRecord::SessionStore::Session.table_name=
wouldn't it make sense that the task uses the table name defined
above?
Tested patch attached...
Comments and changes to this ticket
-
CancelProfileIsBroken August 7th, 2009 @ 01:41 PM
- Tag changed from databases.rake, minor, patch to bugmash, databases.rake, minor, patch
-
pjammer August 8th, 2009 @ 04:34 AM
+1 for this patch. it gives the same functionality as the previous rails version. +1 on the relevance of this ticket. While the code is cleaner, someone who have to change the name of the sessions table manually in order for the name to be changed. With the existing code, the rake task wouldn't work.
However, can you pass an argument to the db:sessions:create task? if not, the only way to change the name is to muck around in the migration.
-
Elad Meidar August 8th, 2009 @ 04:14 PM
+1 for the first patch, +1 for relevancy.
You can change the name by specifying:
ActiveRecord::SessionStore::Session.table_name = 'new_session_table_name'
in environment.rb
Although the patch fixed db:sessions:clear to to use the custom session table name, it didn't apply to db:sessions:create as pjammer applied, i attached a patch that fixes this issue by overriding the default_table_name method in sessions_generator.rb
few things to keep in mind:
- i thought it would be wise to leave the pluralization conditional in tact, in case there is no custom table name (e.c table is still 'sessions' or 'session').
- i supplied a basic test to ensure that the generator is using the right table name, but i did not check the content of the generated migration, i was unable to run the generator.
tried:
g = Rails::Generator::Base.instance('session_migration') g.command(:create).invoke!
which resulted in:
undefined method `timestamped_migrations' for ActiveRecord::Base:Class
-
Dan Croak August 8th, 2009 @ 10:34 PM
What tests should be run to verify this patch?
The fix_sessions patch applies cleanly in 2-3-stable and rake test runs green for railties.
However, I'm not sure I'm running the right tests.
-
Blue Box Jesse September 26th, 2009 @ 10:32 PM
+1
Patch applies cleanly on 2-3-stable.
Railties tests pass.
Seems ready to go!
-
CancelProfileIsBroken September 27th, 2009 @ 11:43 AM
- Tag changed from bugmash, databases.rake, minor, patch to bugmash-review, databases.rake, minor, patch
-
Rizwan Reza May 15th, 2010 @ 06:45 PM
- Tag changed from bugmash-review, databases.rake, minor, patch to bugmash, databases.rake, minor, patch
-
Priit Tamboom May 15th, 2010 @ 09:24 PM
It looks like master's db:sessions:clean already honors
ActiveRecord::SessionStore::Session.table_name:
http://github.com/rails/rails/blob/master/activerecord/lib/active_r...and master's db:sessions:create also honors custom table_name:
http://github.com/rails/rails/blob/master/activerecord/lib/rails/ge...I suggest we can call this ticket fixed for master.
-
jslag May 15th, 2010 @ 10:28 PM
Agree with Priit, master already gets this right.
+1 to closing the ticket.
-
Rizwan Reza May 16th, 2010 @ 03:46 AM
- Tag changed from bugmash, databases.rake, minor, patch to databases.rake, minor, patch
- State changed from new to resolved
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 3008 Rails generators does not take into consideration ActiveRecord::SessionStore::Session.table_name The patch applied on #2745 should also be ported and appl...