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

Commit

Permalink
merge branch.sql into schema.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed May 11, 2016
1 parent 5033e20 commit 8221b8d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
28 changes: 0 additions & 28 deletions sql/branch.sql

This file was deleted.

32 changes: 32 additions & 0 deletions sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -741,3 +741,35 @@ CREATE TABLE countries -- http://www.iso.org/iso/country_codes
);

\i sql/countries.sql


-- https://github.com/gratipay/gratipay.com/pull/4028

CREATE TABLE participant_identities
( id bigserial primary key
, participant_id bigint NOT NULL REFERENCES participants(id)
, country_id bigint NOT NULL REFERENCES countries(id)
, schema_name text NOT NULL
, info bytea NOT NULL
, _info_last_keyed timestamptz NOT NULL DEFAULT now()
, UNIQUE(participant_id, country_id)
);


-- fail_if_no_email

CREATE FUNCTION fail_if_no_email() RETURNS trigger AS $$
BEGIN
IF (SELECT email_address FROM participants WHERE id=NEW.participant_id) IS NULL THEN
RAISE EXCEPTION
USING ERRCODE=23100
, MESSAGE='This operation requires a verified participant email address.';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER enforce_email_for_participant_identity
BEFORE INSERT ON participant_identities
FOR EACH ROW
EXECUTE PROCEDURE fail_if_no_email();

0 comments on commit 8221b8d

Please sign in to comment.