Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Make participant_id mutable in the db (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Sep 12, 2012
1 parent c55cde6 commit 1c2c6d5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
1 change: 0 additions & 1 deletion gittip/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def load_session(where, val):
, p.ctime
, p.claimed_time
, p.is_admin
, p.redirect
, p.balance
, p.goal
, n.network
Expand Down
50 changes: 50 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,53 @@ ALTER TABLE paydays RENAME COLUMN exchange_fees_volume TO charge_fees_volume;
ALTER TABLE paydays ADD COLUMN nachs bigint DEFAULT 0;
ALTER TABLE paydays ADD COLUMN ach_volume numeric(35,2) DEFAULT 0.00;
ALTER TABLE paydays ADD COLUMN ach_fees_volume numeric(35,2) DEFAULT 0.00;


-------------------------------------------------------------------------------
-- https://github.com/whit537/www.gittip.com/issues/80

-- The redirect column ended up being YAGNI. I'm dropping it here because
-- it's implicated in constraints that we'd otherwise have to alter below.

ALTER TABLE participants DROP redirect;

BEGIN;

-- We need to be able to change participant_id and have that cascade out to
-- other tables. Let's do this in a transaction, just for kicks. Kinda
-- gives me the willies to be changing constraints like this. I think it's
-- because I never created the constraints so explicitly in the first
-- place. The below is copied / pasted / edited from `\d participants`.
-- I *think* I'm doing this right. :^O

ALTER TABLE "exchanges" DROP CONSTRAINT "exchanges_participant_id_fkey";
ALTER TABLE "exchanges" ADD CONSTRAINT "exchanges_participant_id_fkey"
FOREIGN KEY (participant_id) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

ALTER TABLE "social_network_users" DROP CONSTRAINT "social_network_users_participant_id_fkey";
ALTER TABLE "social_network_users" ADD CONSTRAINT "social_network_users_participant_id_fkey"
FOREIGN KEY (participant_id) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

ALTER TABLE "tips" DROP CONSTRAINT "tips_tippee_fkey";
ALTER TABLE "tips" ADD CONSTRAINT "tips_tippee_fkey"
FOREIGN KEY (tippee) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

ALTER TABLE "tips" DROP CONSTRAINT "tips_tipper_fkey";
ALTER TABLE "tips" ADD CONSTRAINT "tips_tipper_fkey"
FOREIGN KEY (tipper) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

ALTER TABLE "transfers" DROP CONSTRAINT "transfers_tippee_fkey";
ALTER TABLE "transfers" ADD CONSTRAINT "transfers_tippee_fkey"
FOREIGN KEY (tippee) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

ALTER TABLE "transfers" DROP CONSTRAINT "transfers_tipper_fkey";
ALTER TABLE "transfers" ADD CONSTRAINT "transfers_tipper_fkey"
FOREIGN KEY (tipper) REFERENCES participants(id)
ON UPDATE CASCADE ON DELETE RESTRICT;

END;

0 comments on commit 1c2c6d5

Please sign in to comment.