Getting Issue when running migration but through console its works
<p>When i am running this query through migration it gives Error-</p>

<p>Query -</p>

<pre><code>ActionEvent.includes([:historic_task_allocation, {:task_results =&gt;[:task_result_status, :user]}]).where("action_events.ae_type = 0 AND action_events.result_status &lt;&gt; 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 &lt; action_events.date AND (aul.valid_to &gt; action_events.date OR aul.valid_to IS NULL))")
</code></pre>

<p><strong>Error -</strong></p>

<blockquote>
  <p>Mysql2::Error: Unknown column 'task_allocations.can_complete_late' in
  'field list':</p>
</blockquote>

<p>But through console its work.</p>

<p>Where is the problem?</p>