Some projects have future milestone dates. In order to avoid these future dates from showing up on the projects list, I added this to the WHERE clause on dcp_milestoneproject table in materialized view:
AND mm.dcp_actualenddate::date <= CURRENT_DATE
This way, any milestone dates that are less than or equal to the current date (in the past or the present) will be included in the materialized view.
I then re-added the dcp_name_index to normalized_projects, as this index is removed when the materialized view is dropped and then re-created.
I did this index creation in a separate migration to make it cleaner/easier to remember for future updates, and to make it easier to run. I was having trouble getting the materialized view to run before creating the new indices when they were in the same migration--there's probably a way around this rather than creating a whole new migration--but creating a new migration seemed like the best solution.
Some projects have future milestone dates. In order to avoid these future dates from showing up on the projects list, I added this to the WHERE clause on
dcp_milestoneproject
table in materialized view:AND mm.dcp_actualenddate::date <= CURRENT_DATE
This way, any milestone dates that are less than or equal to the current date (in the past or the present) will be included in the materialized view.
I then re-added the
dcp_name_index
tonormalized_projects
, as this index is removed when the materialized view is dropped and then re-created.I did this index creation in a separate migration to make it cleaner/easier to remember for future updates, and to make it easier to run. I was having trouble getting the materialized view to run before creating the new indices when they were in the same migration--there's probably a way around this rather than creating a whole new migration--but creating a new migration seemed like the best solution.