-- Add up migration script here
CREATE TABLE IF NOT EXISTS google_person (
  id SERIAL PRIMARY KEY,
  resource_name TEXT NOT NULL UNIQUE,
  display_name TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS email_photo (
  id SERIAL PRIMARY KEY,
  google_person_id INTEGER REFERENCES google_person (id) UNIQUE,
  url TEXT NOT NULL
);

CREATE TABLE IF NOT EXISTS email_address (
  id SERIAL PRIMARY KEY,
  address TEXT NOT NULL UNIQUE,
  email_photo_id INTEGER REFERENCES email_photo (id),
  google_person_id INTEGER REFERENCES google_person (id)
);