Skip to content

Commit

Permalink
Remove organization memberships
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
christopherstyles authored and joshsmith committed Mar 18, 2017
1 parent beeaeb8 commit f54e6a3
Show file tree
Hide file tree
Showing 21 changed files with 24 additions and 437 deletions.
6 changes: 0 additions & 6 deletions lib/code_corps/analytics/segment_event_name_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ defmodule CodeCorps.Analytics.SegmentEventNameBuilder do
defp get_event_name(:update, %CodeCorps.DonationGoal{}) do
"Updated Donation Goal"
end
defp get_event_name(:create, %CodeCorps.OrganizationMembership{}) do
"Requested Organization Membership"
end
defp get_event_name(:update, %CodeCorps.OrganizationMembership{}) do
"Approved Organization Membership"
end
defp get_event_name(:create, %CodeCorps.ProjectUser{}) do
"Requested Project Membership"
end
Expand Down
2 changes: 0 additions & 2 deletions lib/code_corps/analytics/segment_tracking_support.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ defmodule CodeCorps.Analytics.SegmentTrackingSupport do
def includes?(:update, %CodeCorps.Comment{}), do: true
def includes?(:create, %CodeCorps.DonationGoal{}), do: true
def includes?(:update, %CodeCorps.DonationGoal{}), do: true
def includes?(:create, %CodeCorps.OrganizationMembership{}), do: true
def includes?(:update, %CodeCorps.OrganizationMembership{}), do: true
def includes?(:create, %CodeCorps.ProjectUser{}), do: true
def includes?(:update, %CodeCorps.ProjectUser{}), do: true
def includes?(:create, %CodeCorps.StripeConnectAccount{}), do: true
Expand Down
8 changes: 0 additions & 8 deletions lib/code_corps/analytics/segment_traits_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ defmodule CodeCorps.Analytics.SegmentTraitsBuilder do
}
end

defp traits(organization_membership = %CodeCorps.OrganizationMembership{}) do
organization_membership = organization_membership |> CodeCorps.Repo.preload(:organization)
%{
organization: organization_membership.organization.name,
organization_id: organization_membership.organization.id
}
end

defp traits(record = %CodeCorps.ProjectUser{}) do
record = record |> CodeCorps.Repo.preload(:project)
%{
Expand Down
2 changes: 1 addition & 1 deletion lib/code_corps/validators/slug_validator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule CodeCorps.Validators.SlugValidator do
images issues
mentions
notifications
oauth oauth_clients organizations organization-memberships
oauth oauth_clients organizations
ping projects project-categories
project-skills
repositories roles
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule CodeCorps.Repo.Migrations.DropOrganizationMembership do
use Ecto.Migration

def up do
drop index :organization_memberships, [:member_id, :organization_id]
drop table(:organization_memberships)
end

def down do
create table(:organization_memberships) do
add :role, :string, null: false
add :organization_id, references(:organizations, on_delete: :nothing), null: false
add :member_id, references(:users, on_delete: :nothing), null: false

timestamps()
end

create index :organization_memberships, [:member_id, :organization_id], unique: true
end
end
45 changes: 0 additions & 45 deletions priv/repo/scripts/migrate_organization_memberships.exs

This file was deleted.

33 changes: 0 additions & 33 deletions priv/repo/scripts/migrate_organization_owners.exs

This file was deleted.

33 changes: 0 additions & 33 deletions priv/repo/scripts/migrate_project_owners.exs

This file was deleted.

73 changes: 1 addition & 72 deletions priv/repo/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,39 +183,6 @@ CREATE SEQUENCE donation_goals_id_seq
ALTER SEQUENCE donation_goals_id_seq OWNED BY donation_goals.id;


--
-- Name: organization_memberships; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE organization_memberships (
id integer NOT NULL,
role character varying(255) NOT NULL,
organization_id integer NOT NULL,
member_id integer NOT NULL,
inserted_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);


--
-- Name: organization_memberships_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE organization_memberships_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: organization_memberships_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE organization_memberships_id_seq OWNED BY organization_memberships.id;


--
-- Name: organizations; Type: TABLE; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1403,13 +1370,6 @@ ALTER TABLE ONLY comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq':
ALTER TABLE ONLY donation_goals ALTER COLUMN id SET DEFAULT nextval('donation_goals_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY organization_memberships ALTER COLUMN id SET DEFAULT nextval('organization_memberships_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1652,14 +1612,6 @@ ALTER TABLE ONLY donation_goals
ADD CONSTRAINT donation_goals_pkey PRIMARY KEY (id);


--
-- Name: organization_memberships_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY organization_memberships
ADD CONSTRAINT organization_memberships_pkey PRIMARY KEY (id);


--
-- Name: organizations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1930,13 +1882,6 @@ CREATE UNIQUE INDEX index_projects_on_user_id_skill_id ON user_skills USING btre
CREATE UNIQUE INDEX index_skills_on_title ON skills USING btree (lower((title)::text));


--
-- Name: organization_memberships_member_id_organization_id_index; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX organization_memberships_member_id_organization_id_index ON organization_memberships USING btree (member_id, organization_id);


--
-- Name: organizations_approved_index; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2284,22 +2229,6 @@ ALTER TABLE ONLY donation_goals
ADD CONSTRAINT donation_goals_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id);


--
-- Name: organization_memberships_member_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY organization_memberships
ADD CONSTRAINT organization_memberships_member_id_fkey FOREIGN KEY (member_id) REFERENCES users(id);


--
-- Name: organization_memberships_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY organization_memberships
ADD CONSTRAINT organization_memberships_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id);


--
-- Name: organizations_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
Expand Down Expand Up @@ -2664,5 +2593,5 @@ ALTER TABLE ONLY user_tasks
-- PostgreSQL database dump complete
--

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);
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);

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ defmodule CodeCorps.Analytics.SegmentEventNameBuilderTest do
assert SegmentEventNameBuilder.build(:update, build(:comment)) == "Edited Comment"
end

test "with organization membership" do
assert SegmentEventNameBuilder.build(:create, build(:organization_membership)) == "Requested Organization Membership"
assert SegmentEventNameBuilder.build(:update, build(:organization_membership)) == "Approved Organization Membership"
end

test "with project_user" do
assert SegmentEventNameBuilder.build(:create, build(:project_user)) == "Requested Project Membership"
assert SegmentEventNameBuilder.build(:update, build(:project_user)) == "Approved Project Membership"
Expand Down

0 comments on commit f54e6a3

Please sign in to comment.