Skip to content

Commit f54e6a3

Browse files
christopherstylesjoshsmith
authored andcommitted
Remove organization memberships
This update drops the `organization_memberships` table, removes all related temporary migration tasks from the `priv/repo/scripts` directory and removes all occurrences of organization memberships throughout the API codebase. Resolves #718.
1 parent beeaeb8 commit f54e6a3

21 files changed

+24
-437
lines changed

lib/code_corps/analytics/segment_event_name_builder.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ defmodule CodeCorps.Analytics.SegmentEventNameBuilder do
1414
defp get_event_name(:update, %CodeCorps.DonationGoal{}) do
1515
"Updated Donation Goal"
1616
end
17-
defp get_event_name(:create, %CodeCorps.OrganizationMembership{}) do
18-
"Requested Organization Membership"
19-
end
20-
defp get_event_name(:update, %CodeCorps.OrganizationMembership{}) do
21-
"Approved Organization Membership"
22-
end
2317
defp get_event_name(:create, %CodeCorps.ProjectUser{}) do
2418
"Requested Project Membership"
2519
end

lib/code_corps/analytics/segment_tracking_support.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ defmodule CodeCorps.Analytics.SegmentTrackingSupport do
1111
def includes?(:update, %CodeCorps.Comment{}), do: true
1212
def includes?(:create, %CodeCorps.DonationGoal{}), do: true
1313
def includes?(:update, %CodeCorps.DonationGoal{}), do: true
14-
def includes?(:create, %CodeCorps.OrganizationMembership{}), do: true
15-
def includes?(:update, %CodeCorps.OrganizationMembership{}), do: true
1614
def includes?(:create, %CodeCorps.ProjectUser{}), do: true
1715
def includes?(:update, %CodeCorps.ProjectUser{}), do: true
1816
def includes?(:create, %CodeCorps.StripeConnectAccount{}), do: true

lib/code_corps/analytics/segment_traits_builder.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ defmodule CodeCorps.Analytics.SegmentTraitsBuilder do
3030
}
3131
end
3232

33-
defp traits(organization_membership = %CodeCorps.OrganizationMembership{}) do
34-
organization_membership = organization_membership |> CodeCorps.Repo.preload(:organization)
35-
%{
36-
organization: organization_membership.organization.name,
37-
organization_id: organization_membership.organization.id
38-
}
39-
end
40-
4133
defp traits(record = %CodeCorps.ProjectUser{}) do
4234
record = record |> CodeCorps.Repo.preload(:project)
4335
%{

lib/code_corps/validators/slug_validator.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule CodeCorps.Validators.SlugValidator do
3434
images issues
3535
mentions
3636
notifications
37-
oauth oauth_clients organizations organization-memberships
37+
oauth oauth_clients organizations
3838
ping projects project-categories
3939
project-skills
4040
repositories roles
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
defmodule CodeCorps.Repo.Migrations.DropOrganizationMembership do
2+
use Ecto.Migration
3+
4+
def up do
5+
drop index :organization_memberships, [:member_id, :organization_id]
6+
drop table(:organization_memberships)
7+
end
8+
9+
def down do
10+
create table(:organization_memberships) do
11+
add :role, :string, null: false
12+
add :organization_id, references(:organizations, on_delete: :nothing), null: false
13+
add :member_id, references(:users, on_delete: :nothing), null: false
14+
15+
timestamps()
16+
end
17+
18+
create index :organization_memberships, [:member_id, :organization_id], unique: true
19+
end
20+
end

priv/repo/scripts/migrate_organization_memberships.exs

Lines changed: 0 additions & 45 deletions
This file was deleted.

priv/repo/scripts/migrate_organization_owners.exs

Lines changed: 0 additions & 33 deletions
This file was deleted.

priv/repo/scripts/migrate_project_owners.exs

Lines changed: 0 additions & 33 deletions
This file was deleted.

priv/repo/structure.sql

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -183,39 +183,6 @@ CREATE SEQUENCE donation_goals_id_seq
183183
ALTER SEQUENCE donation_goals_id_seq OWNED BY donation_goals.id;
184184

185185

186-
--
187-
-- Name: organization_memberships; Type: TABLE; Schema: public; Owner: -
188-
--
189-
190-
CREATE TABLE organization_memberships (
191-
id integer NOT NULL,
192-
role character varying(255) NOT NULL,
193-
organization_id integer NOT NULL,
194-
member_id integer NOT NULL,
195-
inserted_at timestamp without time zone NOT NULL,
196-
updated_at timestamp without time zone NOT NULL
197-
);
198-
199-
200-
--
201-
-- Name: organization_memberships_id_seq; Type: SEQUENCE; Schema: public; Owner: -
202-
--
203-
204-
CREATE SEQUENCE organization_memberships_id_seq
205-
START WITH 1
206-
INCREMENT BY 1
207-
NO MINVALUE
208-
NO MAXVALUE
209-
CACHE 1;
210-
211-
212-
--
213-
-- Name: organization_memberships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
214-
--
215-
216-
ALTER SEQUENCE organization_memberships_id_seq OWNED BY organization_memberships.id;
217-
218-
219186
--
220187
-- Name: organizations; Type: TABLE; Schema: public; Owner: -
221188
--
@@ -1403,13 +1370,6 @@ ALTER TABLE ONLY comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq':
14031370
ALTER TABLE ONLY donation_goals ALTER COLUMN id SET DEFAULT nextval('donation_goals_id_seq'::regclass);
14041371

14051372

1406-
--
1407-
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
1408-
--
1409-
1410-
ALTER TABLE ONLY organization_memberships ALTER COLUMN id SET DEFAULT nextval('organization_memberships_id_seq'::regclass);
1411-
1412-
14131373
--
14141374
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
14151375
--
@@ -1652,14 +1612,6 @@ ALTER TABLE ONLY donation_goals
16521612
ADD CONSTRAINT donation_goals_pkey PRIMARY KEY (id);
16531613

16541614

1655-
--
1656-
-- Name: organization_memberships_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1657-
--
1658-
1659-
ALTER TABLE ONLY organization_memberships
1660-
ADD CONSTRAINT organization_memberships_pkey PRIMARY KEY (id);
1661-
1662-
16631615
--
16641616
-- Name: organizations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
16651617
--
@@ -1930,13 +1882,6 @@ CREATE UNIQUE INDEX index_projects_on_user_id_skill_id ON user_skills USING btre
19301882
CREATE UNIQUE INDEX index_skills_on_title ON skills USING btree (lower((title)::text));
19311883

19321884

1933-
--
1934-
-- Name: organization_memberships_member_id_organization_id_index; Type: INDEX; Schema: public; Owner: -
1935-
--
1936-
1937-
CREATE UNIQUE INDEX organization_memberships_member_id_organization_id_index ON organization_memberships USING btree (member_id, organization_id);
1938-
1939-
19401885
--
19411886
-- Name: organizations_approved_index; Type: INDEX; Schema: public; Owner: -
19421887
--
@@ -2284,22 +2229,6 @@ ALTER TABLE ONLY donation_goals
22842229
ADD CONSTRAINT donation_goals_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id);
22852230

22862231

2287-
--
2288-
-- Name: organization_memberships_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2289-
--
2290-
2291-
ALTER TABLE ONLY organization_memberships
2292-
ADD CONSTRAINT organization_memberships_member_id_fkey FOREIGN KEY (member_id) REFERENCES users(id);
2293-
2294-
2295-
--
2296-
-- Name: organization_memberships_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
2297-
--
2298-
2299-
ALTER TABLE ONLY organization_memberships
2300-
ADD CONSTRAINT organization_memberships_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id);
2301-
2302-
23032232
--
23042233
-- Name: organizations_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
23052234
--
@@ -2664,5 +2593,5 @@ ALTER TABLE ONLY user_tasks
26642593
-- PostgreSQL database dump complete
26652594
--
26662595

2667-
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224), (20170224233516), (20170226050552), (20170228085250), (20170308214128), (20170308220713), (20170308222552), (20170313130611), (20170318032449);
2596+
INSERT INTO "schema_migrations" (version) VALUES (20160723215749), (20160804000000), (20160804001111), (20160805132301), (20160805203929), (20160808143454), (20160809214736), (20160810124357), (20160815125009), (20160815143002), (20160816020347), (20160816034021), (20160817220118), (20160818000944), (20160818132546), (20160820113856), (20160820164905), (20160822002438), (20160822004056), (20160822011624), (20160822020401), (20160822044612), (20160830081224), (20160830224802), (20160911233738), (20160912002705), (20160912145957), (20160918003206), (20160928232404), (20161003185918), (20161019090945), (20161019110737), (20161020144622), (20161021131026), (20161031001615), (20161121005339), (20161121014050), (20161121043941), (20161121045709), (20161122015942), (20161123081114), (20161123150943), (20161124085742), (20161125200620), (20161126045705), (20161127054559), (20161205024856), (20161207112519), (20161209192504), (20161212005641), (20161214005935), (20161215052051), (20161216051447), (20161218005913), (20161219160401), (20161219163909), (20161220141753), (20161221085759), (20161226213600), (20161231063614), (20170102130055), (20170102181053), (20170104113708), (20170104212623), (20170104235423), (20170106013143), (20170115035159), (20170115230549), (20170121014100), (20170131234029), (20170201014901), (20170201025454), (20170201035458), (20170201183258), (20170220032224), (20170224233516), (20170226050552), (20170228085250), (20170308214128), (20170308220713), (20170308222552), (20170313130611), (20170318032449), (20170318082740);
26682597

test/lib/code_corps/analytics/segment_event_name_builder_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ defmodule CodeCorps.Analytics.SegmentEventNameBuilderTest do
1313
assert SegmentEventNameBuilder.build(:update, build(:comment)) == "Edited Comment"
1414
end
1515

16-
test "with organization membership" do
17-
assert SegmentEventNameBuilder.build(:create, build(:organization_membership)) == "Requested Organization Membership"
18-
assert SegmentEventNameBuilder.build(:update, build(:organization_membership)) == "Approved Organization Membership"
19-
end
20-
2116
test "with project_user" do
2217
assert SegmentEventNameBuilder.build(:create, build(:project_user)) == "Requested Project Membership"
2318
assert SegmentEventNameBuilder.build(:update, build(:project_user)) == "Approved Project Membership"

0 commit comments

Comments
 (0)