Defect #2699

db:migrate does not take into account custom table prefix

Added by Stefan Urbanek over 13 years ago. Updated over 13 years ago.

Status:ClosedStart date:2009-02-08
Priority:NormalDue date:
Assignee:-% Done:


Target version:0.8.1
Resolution:Fixed Affected version:


I need to have a table prefix for redmine, so I have put this in the environment.db file:
config.active_record.table_name_prefix = 'rm_'

When I do "rake db:migrate" to initialize redmine, it fails at: SetTopicAuthorsAsWatchers with following message:

==  SetTopicAuthorsAsWatchers: migrating ======================================
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Table 'my_scheme.watchers' doesn't exist: INSERT INTO watchers (watchable_type, watchable_id, user_id) SELECT DISTINCT 'Message', COALESCE(messages.parent_id,, messages.author_id FROM messages, users WHERE messages.author_id = AND users.status = 1

Very quick fix is to put the prefix into the INSERT statement. For example, I have prefix rm_ so I change it to:

INSERT INTO rm_watchers ..... FROM rm_messages messages, rm_users users....

I have no time now to find proper solution, I am just writing it here to let you know, that this issue exists.


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

  • Status changed from New to Resolved
  • Target version set to 0.8.1
  • Affected version (unused) set to devel
  • Resolution set to Fixed

This is fixed in r2415. Thanks.

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

  • Status changed from Resolved to Closed

Merged in 0.8 branch in r2425.

Also available in: Atom PDF