我rake aborted!
uninitialized constant CreateConversationsSummaries
在运行时得到一个rake:db migrate
。我正在尝试使用 SQL 来汇总对话信息。
我的迁移:
class CreateConversationSummaries < ActiveRecord::Migration
def up
execute <<-SQL
CREATE VIEW conversation_summaries AS
SELECT c.id,
s.name as sender_name,
r.name as recipient_name
FROM conversations c
inner join users r on r.id = c.recipient_id
inner join users s on s.id = c.sender_id
SQL
end
def down
execute 'DROP VIEW conversation_summaries'
end
end
会不会和我之前做的迁移冲突?
class CreateConversations < ActiveRecord::Migration
def change
create_table :conversations do |t|
t.string :sender_id
t.string :recipient_id
t.string :subject
t.timestamps
end
end
end