Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions db/main/migrate/20231206113245_add_unique_vcs_id_type_indexes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class AddUniqueVcsIdTypeIndexes < ActiveRecord::Migration[5.2]
disable_ddl_transaction!

def change
remove_index :repositories, column: [:vcs_id, :vcs_type], algorithm: :concurrently
add_index :repositories, [:vcs_id, :vcs_type], algorithm: :concurrently, unique: true
remove_index :organizations, column: [:vcs_id, :vcs_type], algorithm: :concurrently
add_index :organizations, [:vcs_id, :vcs_type], algorithm: :concurrently, unique: true
remove_index :users, column: [:vcs_id, :vcs_type], algorithm: :concurrently
add_index :users, [:vcs_id, :vcs_type], algorithm: :concurrently, unique: true
end
end
43 changes: 22 additions & 21 deletions db/main/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4478,13 +4478,6 @@ CREATE UNIQUE INDEX index_organizations_on_org_id ON public.organizations USING
CREATE INDEX index_organizations_on_updated_at ON public.organizations USING btree (updated_at);


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

CREATE INDEX index_organizations_on_vcs_id_and_vcs_type ON public.organizations USING btree (vcs_id, vcs_type);


--
-- Name: index_owner_groups_on_owner_type_and_owner_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -4730,13 +4723,6 @@ CREATE INDEX index_repositories_on_slug_or_names ON public.repositories USING bt
CREATE INDEX index_repositories_on_updated_at ON public.repositories USING btree (updated_at);


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

CREATE INDEX index_repositories_on_vcs_id_and_vcs_type ON public.repositories USING btree (vcs_id, vcs_type);


--
-- Name: index_repositories_on_vcs_type_and_vcs_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -5151,24 +5137,38 @@ CREATE INDEX index_users_on_updated_at ON public.users USING btree (updated_at);


--
-- Name: index_users_on_vcs_id_and_vcs_type; Type: INDEX; Schema: public; Owner: -
-- Name: index_users_on_vcs_type_and_vcs_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_vcs_id_and_vcs_type ON public.users USING btree (vcs_id, vcs_type);
CREATE INDEX index_users_on_vcs_type_and_vcs_id ON public.users USING btree (vcs_type, vcs_id);


--
-- Name: index_users_on_vcs_type_and_vcs_id; Type: INDEX; Schema: public; Owner: -
-- Name: managed_repositories_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_users_on_vcs_type_and_vcs_id ON public.users USING btree (vcs_type, vcs_id);
CREATE INDEX managed_repositories_idx ON public.repositories USING btree (managed_by_installation_at);


--
-- Name: managed_repositories_idx; Type: INDEX; Schema: public; Owner: -
-- Name: index_repositories_on_vcs_id_and_vcs_type; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX managed_repositories_idx ON public.repositories USING btree (managed_by_installation_at);
CREATE UNIQUE INDEX index_repositories_on_vcs_id_and_vcs_type ON public.repositories USING btree (vcs_id, vcs_type);


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

CREATE UNIQUE INDEX index_organizations_on_vcs_id_and_vcs_type ON public.organizations USING btree (vcs_id, vcs_type);


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

CREATE UNIQUE INDEX index_users_on_vcs_id_and_vcs_type ON public.users USING btree (vcs_id, vcs_type);


--
Expand Down Expand Up @@ -5969,6 +5969,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20220825140522'),
('20220905144600'),
('20221214171030'),
('20230208161446');
('20230208161446'),
('20231206113245');