在运行迁移时获取问题,但通过控制台运行

时间:2016-01-11 09:41:03

标签: ruby-on-rails-3 rails-migrations

当我通过迁移运行此查询时,它会给出错误 -

查询 -

ActionEvent.includes([:historic_task_allocation, {:task_results =>[:task_result_status, :user]}]).where("action_events.ae_type = 0 AND action_events.result_status <> 2 AND task_result_statuses.is_completion AND users.id NOT IN (SELECT user_id FROM allocation_user_links aul WHERE aul.task_allocation_id = task_allocations.id AND aul.valid_from < action_events.date AND (aul.valid_to > action_events.date OR aul.valid_to IS NULL))")

错误 -

  

Mysql2 ::错误:未知列'task_allocations.can_complete_late'中   '字段列表':

但通过安慰它的工作。

问题出在哪里?

1 个答案:

答案 0 :(得分:0)

已解决此问题只需在self.up方法中的查询上方添加以下行。

  TaskAllocation.reset_column_information  # Resets all the cached information about columns, which will cause them to be reloaded on the next request.