diff --git a/crates/db_schema/replaceable_schema/triggers.sql b/crates/db_schema/replaceable_schema/triggers.sql index 98af3e546..87866e89c 100644 --- a/crates/db_schema/replaceable_schema/triggers.sql +++ b/crates/db_schema/replaceable_schema/triggers.sql @@ -486,7 +486,7 @@ BEGIN INNER JOIN old_post ON old_post.id = new_post.id AND (old_post.featured_community, old_post.featured_local) != (new_post.featured_community, - old_post.featured_local) + new_post.featured_local) WHERE post_aggregates.post_id = new_post.id; RETURN NULL; diff --git a/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/down.sql b/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/down.sql new file mode 100644 index 000000000..9ca12fc18 --- /dev/null +++ b/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/down.sql @@ -0,0 +1,3 @@ +SELECT +; + diff --git a/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/up.sql b/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/up.sql new file mode 100644 index 000000000..3bb6e16b1 --- /dev/null +++ b/migrations/2024-06-17-160323_fix_post_aggregates_featured_local/up.sql @@ -0,0 +1,11 @@ +-- Fix rows that were not updated because of the old incorrect trigger +UPDATE + post_aggregates +SET + featured_local = post.featured_local +FROM + post +WHERE + post.id = post_aggregates.post_id + AND post.featured_local != post_aggregates.featured_local; +