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 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`memberships` was a bad name for this table because it's ambiguous with community memberships. Renaming to `takes` fits the usage we've arrived at and is parallel to `tips`. Tips and takes! Membership is then an emergent property of data recorded in the takes table.
- Loading branch information
1 parent
a0d4cce
commit bf08077
Showing
7 changed files
with
103 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
------------------------------------------------------------------------------- | ||
-- https://github.com/gittip/www.gittip.com/issues/2282 | ||
|
||
BEGIN; | ||
|
||
|
||
-- takes table | ||
ALTER TABLE memberships RENAME TO takes; | ||
ALTER TABLE takes RENAME COLUMN take TO amount; | ||
|
||
ALTER TABLE takes DROP CONSTRAINT "memberships_pkey"; | ||
ALTER TABLE takes ADD CONSTRAINT "takes_pkey" | ||
PRIMARY KEY (id); | ||
|
||
ALTER TABLE takes DROP constraint "memberships_member_fkey"; | ||
ALTER TABLE takes ADD constraint "takes_member_fkey" | ||
FOREIGN KEY (member) REFERENCES participants(username) | ||
ON UPDATE CASCADE ON DELETE RESTRICT; | ||
|
||
ALTER TABLE takes DROP constraint "memberships_team_fkey"; | ||
ALTER TABLE takes ADD constraint "takes_team_fkey" | ||
FOREIGN KEY (team) REFERENCES participants(username) | ||
ON UPDATE CASCADE ON DELETE RESTRICT; | ||
|
||
ALTER TABLE takes DROP constraint "memberships_recorder_fkey"; | ||
ALTER TABLE takes ADD constraint "takes_recorder_fkey" | ||
FOREIGN KEY (recorder) REFERENCES participants(username) | ||
ON UPDATE CASCADE ON DELETE RESTRICT; | ||
|
||
ALTER SEQUENCE memberships_id_seq RENAME TO takes_id_seq; | ||
|
||
|
||
-- current_takes view | ||
DROP VIEW current_memberships; | ||
CREATE VIEW current_takes AS | ||
SELECT * FROM ( | ||
|
||
SELECT DISTINCT ON (member, team) m.* | ||
FROM takes m | ||
JOIN participants p1 ON p1.username = member | ||
JOIN participants p2 ON p2.username = team | ||
WHERE p1.is_suspicious IS NOT TRUE | ||
AND p2.is_suspicious IS NOT TRUE | ||
ORDER BY member | ||
, team | ||
, mtime DESC | ||
|
||
) AS anon WHERE amount > 0; | ||
|
||
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
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
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