diff --git a/db/migration/V0001__Create_members_table.sql b/db/migration/V0001__Create_members_table.sql new file mode 100644 index 0000000..e032b27 --- /dev/null +++ b/db/migration/V0001__Create_members_table.sql @@ -0,0 +1,23 @@ +CREATE TYPE match_prefs AS ENUM ('mentor', 'mentee', 'both'); +CREATE TYPE industries AS ENUM ( + 'technology', 'finance', 'healthcare', 'education', + 'consulting', 'government', 'nonprofit', 'other' +); + + +CREATE TABLE IF NOT EXISTS "members" ( + id UUID PRIMARY KEY, + full_name TEXT NOT NULL, + email TEXT UNIQUE NOT NULL, + linked_url TEXT, + bio TEXT, + referral_source TEXT, + active BOOLEAN, + match_pref match_prefs, + industry industries, + role TEXT, + topics TEXT[], + extra_notes TEXT, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); diff --git a/db/migration/V0002__Create_match_cycles_table.sql b/db/migration/V0002__Create_match_cycles_table.sql new file mode 100644 index 0000000..c04bf9a --- /dev/null +++ b/db/migration/V0002__Create_match_cycles_table.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS "match_cycles" ( + id UUID PRIMARY KEY, + period TEXT, + run_at TIMESTAMPTZ NOT NULL, + total_members INT, + total_matched INT, + unmatched_id UUID[] +); diff --git a/db/migration/V0003__Create_matches_table.sql b/db/migration/V0003__Create_matches_table.sql new file mode 100644 index 0000000..d6efdfc --- /dev/null +++ b/db/migration/V0003__Create_matches_table.sql @@ -0,0 +1,24 @@ +CREATE TYPE match_status AS ENUM ( + 'pending', + 'accepted', + 'declined', + 'active', + 'paused', + 'completed', + 'cancelled' +); + +CREATE TABLE IF NOT EXISTS "matches" ( + id UUID PRIMARY KEY, + member_a_id UUID NOT NULL, + member_b_id UUID NOT NULL, + cycle_id UUID NOT NULL, + CONSTRAINT fk_member_a FOREIGN KEY (member_a_id) REFERENCES members(id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT fk_member_b FOREIGN KEY (member_b_id) REFERENCES members(id) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT fk_cycle FOREIGN KEY (cycle_id) REFERENCES match_cycles(id) ON DELETE CASCADE ON UPDATE CASCADE, + match_score REAL, + status match_status, + feedback_a INT, + feedback_b INT, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +);