Skip to content

Commit ac94e7d

Browse files
authored
Merge pull request #191 from UW-Macrostrat/people
People
2 parents 05ead0a + e6456d4 commit ac94e7d

File tree

1 file changed

+54
-0
lines changed
  • cli/macrostrat/cli/database/migrations/people

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
-- SCHEMA
2+
CREATE SCHEMA IF NOT EXISTS ecosystem;
3+
4+
-- PEOPLE
5+
CREATE TABLE IF NOT EXISTS ecosystem.people (
6+
id serial PRIMARY KEY,
7+
name text NOT NULL,
8+
email text NOT NULL UNIQUE,
9+
title text NOT NULL,
10+
website text,
11+
img_id text,
12+
active_start timestamp with time zone NOT NULL DEFAULT now(),
13+
active_end timestamp with time zone
14+
);
15+
16+
-- ROLES
17+
CREATE TABLE IF NOT EXISTS ecosystem.roles (
18+
id serial PRIMARY KEY,
19+
name text NOT NULL UNIQUE,
20+
description text NOT NULL
21+
);
22+
23+
-- PEOPLE-ROLES MAPPING
24+
CREATE TABLE IF NOT EXISTS ecosystem.people_roles (
25+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
26+
role_id integer NOT NULL REFERENCES ecosystem.roles(id) ON DELETE CASCADE,
27+
PRIMARY KEY (person_id, role_id)
28+
);
29+
30+
-- CONTRIBUTIONS
31+
CREATE TABLE IF NOT EXISTS ecosystem.contributions (
32+
id serial PRIMARY KEY,
33+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
34+
contribution text NOT NULL,
35+
description text,
36+
date timestamp with time zone NOT NULL DEFAULT now(),
37+
url text
38+
);
39+
40+
-- PEOPLE-CONTRIBUTIONS MAPPING
41+
CREATE TABLE IF NOT EXISTS ecosystem.people_contributions (
42+
person_id integer NOT NULL REFERENCES ecosystem.people(id) ON DELETE CASCADE,
43+
contribution_id integer NOT NULL REFERENCES ecosystem.contributions(id) ON DELETE CASCADE,
44+
PRIMARY KEY (person_id, contribution_id)
45+
);
46+
47+
-- PREPOPULATE ROLES
48+
INSERT INTO ecosystem.roles (name, description) VALUES
49+
('Student', 'Currently enrolled in an academic program'),
50+
('Researcher', 'Conducts academic or applied research'),
51+
('Developer', 'Writes and maintains software code'),
52+
('Leader', 'Leads research or development projects and mentors others'),
53+
('Collaborator', 'Contributes to joint projects'),
54+
ON CONFLICT (name) DO NOTHING;

0 commit comments

Comments
 (0)