Defect #18

table_name_pre/suffix support

Added by Satoru KURASHIKI over 15 years ago. Updated over 15 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution: Affected version:


Rails supports DB table namespaces with ActiveRecord::Base.table_name_pre/suffix.
This will be valuable for some hosting services(users can use only one db).
I tried with MySQL, but it doesn't work well.

1)db:migrate works fine.
After I added this line to config/environment.rb, 'rake db:migrate' created prefixed tables correctly.
ActiveRecord::Base.table_name_prefix = 'redmine_'

2)app/models couldn't handle prefixed tables.
Almost all actions failed, because SQL sentences couldn't find coded table_names.
(ex. "news.created_on DESC" will search 'news' table, but 'redmine_news' exists)


#1 Updated by Jean-Philippe Lang over 15 years ago

Fix has just been committed in the repository.
Let me know if you find any other problem.


#2 Updated by Jean-Philippe Lang over 15 years ago

You're right. Tables names are hard coded in sql fragments when
they need to be specified.
I'll have to replace these hard coded names with something like
this Model.table_name. I'll try do it asap.


Also available in: Atom PDF