-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
postgres migration for updating the RULE to be v14 compatible (#1668)
* postgres migration for updating the RULE to be v14 compatible * update the problematic rule in place also * Add note about applying new migration for pg 14 --------- Co-authored-by: Christopher Small <[email protected]>
- Loading branch information
1 parent
14ae6d4
commit fcd6a10
Showing
3 changed files
with
27 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- This migration fixes an issue with a poorly specified rule definition in the original 000000_initial.sql schema. | ||
-- The old specification worked on Postgres 13, but not longer does on Postgres 14. | ||
-- Consequently, if you set up your Polis database prior to April 9th, 2023, and wish to upgrade to Postgres 14, | ||
-- you should run this migration first. | ||
|
||
DROP RULE IF EXISTS on_vote_insert_update_unique_table ON votes; | ||
|
||
CREATE RULE on_vote_insert_update_unique_table AS | ||
ON INSERT TO votes | ||
DO ALSO | ||
INSERT INTO votes_latest_unique (zid, pid, tid, vote, weight_x_32767, modified) | ||
values (NEW.zid, NEW.pid, NEW.tid, NEW.vote, NEW.weight_x_32767, NEW.created) | ||
ON CONFLICT (zid, pid, tid) DO UPDATE SET vote = excluded.vote, modified = excluded.modified; |