Skip to content

Commit f9f151f

Browse files
authored
Merge pull request #1080 from code-corps/1076-add-missing-github-id-indexes
Add missing indexes for github_id to GithubComment, GithubIssue, GithubRepo
2 parents a8dd7b2 + cc21eee commit f9f151f

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

lib/code_corps/model/github_comment.ex

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ defmodule CodeCorps.GithubComment do
2121
struct
2222
|> Changeset.cast(params, [:body, :github_created_at, :github_id, :github_updated_at, :html_url, :url])
2323
|> Changeset.validate_required([:body, :github_created_at, :github_id, :github_updated_at, :html_url, :url])
24+
|> Changeset.unique_constraint(:github_id)
2425
end
2526

2627
@doc ~S"""

lib/code_corps/model/github_issue.ex

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ defmodule CodeCorps.GithubIssue do
2828
struct
2929
|> cast(params, [:body, :closed_at, :comments_url, :events_url, :github_created_at, :github_id, :github_updated_at, :html_url, :labels_url, :locked, :number, :state, :title, :url])
3030
|> validate_required([:comments_url, :events_url, :github_created_at, :github_id, :github_updated_at, :html_url, :labels_url, :locked, :number, :state, :title, :url])
31+
|> unique_constraint(:github_id)
3132
end
3233

3334
def create_changeset(struct, params) do

lib/code_corps/model/github_pull_request.ex

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ defmodule CodeCorps.GithubPullRequest do
5757
struct
5858
|> cast(params, @attrs)
5959
|> validate_required(@required_attrs)
60+
|> unique_constraint(:github_id)
6061
end
6162

6263
def create_changeset(struct, params) do
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule CodeCorps.Repo.Migrations.AddMissingGithubIdIndexes do
2+
use Ecto.Migration
3+
4+
def change do
5+
create index(:github_comments, [:github_id], unique: true)
6+
create index(:github_issues, [:github_id], unique: true)
7+
create index(:github_repos, [:github_id], unique: true)
8+
end
9+
end

priv/repo/structure.sql

+22-1
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,20 @@ CREATE INDEX github_app_installations_project_id_index ON github_app_installatio
23822382
CREATE INDEX github_app_installations_user_id_index ON github_app_installations USING btree (user_id);
23832383

23842384

2385+
--
2386+
-- Name: github_comments_github_id_index; Type: INDEX; Schema: public; Owner: -
2387+
--
2388+
2389+
CREATE UNIQUE INDEX github_comments_github_id_index ON github_comments USING btree (github_id);
2390+
2391+
2392+
--
2393+
-- Name: github_issues_github_id_index; Type: INDEX; Schema: public; Owner: -
2394+
--
2395+
2396+
CREATE UNIQUE INDEX github_issues_github_id_index ON github_issues USING btree (github_id);
2397+
2398+
23852399
--
23862400
-- Name: github_pull_requests_github_id_index; Type: INDEX; Schema: public; Owner: -
23872401
--
@@ -2396,6 +2410,13 @@ CREATE UNIQUE INDEX github_pull_requests_github_id_index ON github_pull_requests
23962410
CREATE INDEX github_repos_github_app_installation_id_index ON github_repos USING btree (github_app_installation_id);
23972411

23982412

2413+
--
2414+
-- Name: github_repos_github_id_index; Type: INDEX; Schema: public; Owner: -
2415+
--
2416+
2417+
CREATE UNIQUE INDEX github_repos_github_id_index ON github_repos USING btree (github_id);
2418+
2419+
23992420
--
24002421
-- Name: index_categories_on_slug; Type: INDEX; Schema: public; Owner: -
24012422
--
@@ -3296,5 +3317,5 @@ ALTER TABLE ONLY user_tasks
32963317
-- PostgreSQL database dump complete
32973318
--
32983319

3299-
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), (20170324194827), (20170424215355), (20170501225441), (20170505224222), (20170526095401), (20170602000208), (20170622205732), (20170626231059), (20170628092119), (20170628213609), (20170629183404), (20170630140136), (20170706132431), (20170707213648), (20170711122252), (20170717092127), (20170725060612), (20170727052644), (20170731130121), (20170814131722), (20170913114958), (20170921014405), (20170925214512), (20170925230419), (20170926134646), (20170927100300), (20170928234412), (20171003134956), (20171003225853), (20171006063358), (20171006161407), (20171012215106), (20171012221231), (20171016125229), (20171016125516), (20171016223356), (20171016235656);
3320+
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), (20170324194827), (20170424215355), (20170501225441), (20170505224222), (20170526095401), (20170602000208), (20170622205732), (20170626231059), (20170628092119), (20170628213609), (20170629183404), (20170630140136), (20170706132431), (20170707213648), (20170711122252), (20170717092127), (20170725060612), (20170727052644), (20170731130121), (20170814131722), (20170913114958), (20170921014405), (20170925214512), (20170925230419), (20170926134646), (20170927100300), (20170928234412), (20171003134956), (20171003225853), (20171006063358), (20171006161407), (20171012215106), (20171012221231), (20171016125229), (20171016125516), (20171016223356), (20171016235656), (20171017235433);
33003321

0 commit comments

Comments
 (0)