This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3535 from gratipay/1.0-balances
implement a flag for paying out Gratipay 1.0 balances
- Loading branch information
Showing
5 changed files
with
120 additions
and
57 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
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,26 @@ | ||
BEGIN; | ||
|
||
CREATE TYPE status_of_1_0_balance AS ENUM | ||
('unresolved', 'pending-payout', 'resolved'); | ||
|
||
ALTER TABLE participants | ||
ADD COLUMN status_of_1_0_balance status_of_1_0_balance | ||
NOT NULL | ||
DEFAULT 'unresolved'; | ||
|
||
CREATE FUNCTION set_status_of_1_0_balance_to_resolved() RETURNS trigger AS $$ | ||
BEGIN | ||
UPDATE participants | ||
SET status_of_1_0_balance='resolved' | ||
WHERE id = NEW.id; | ||
RETURN NULL; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
CREATE TRIGGER update_status_of_1_0_balance | ||
AFTER UPDATE OF balance ON participants | ||
FOR EACH ROW | ||
WHEN (OLD.balance > 0 AND NEW.balance = 0) | ||
EXECUTE PROCEDURE set_status_of_1_0_balance_to_resolved(); | ||
|
||
END; |
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