Skip to content

Commit

Permalink
Create unique keys
Browse files Browse the repository at this point in the history
  • Loading branch information
SepsiLaszlo authored and balintkiraly committed Jul 27, 2020
1 parent 7ae16ba commit e4d5e49
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/models/entry_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#
# Indexes
#
# bel_tipus_idx (entry_type)
# bel_tipus_idx (entry_type)
# index_entry_requests_on_evaluation_id_and_user_id (evaluation_id,user_id) UNIQUE
#
# Foreign Keys
#
Expand Down
4 changes: 4 additions & 0 deletions app/models/point_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# point_request_id :integer
# principle_id :integer
#
# Indexes
#
# index_point_details_on_principle_id_and_point_request_id (principle_id,point_request_id) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (point_request_id => point_requests.id)
Expand Down
4 changes: 4 additions & 0 deletions app/models/point_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# semester :string(9) not null
# user_id :bigint not null
#
# Indexes
#
# index_point_histories_on_user_id_and_semester (user_id,semester) UNIQUE
#
# Foreign Keys
#
# point_history_usr_id_fkey (user_id => users.id)
Expand Down
3 changes: 2 additions & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#
# Indexes
#
# poszt_fk_idx (membership_id)
# index_posts_on_membership_id_and_post_type_id (membership_id,post_type_id) UNIQUE
# poszt_fk_idx (membership_id)
#
# Foreign Keys
#
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20200722171738_add_index_to_entry_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToEntryRequest < ActiveRecord::Migration[5.0]
def change
add_index :entry_requests, [:evaluation_id, :user_id], unique: true
end
end
5 changes: 5 additions & 0 deletions db/migrate/20200722171937_add_index_to_point_detail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToPointDetail < ActiveRecord::Migration[5.0]
def change
add_index :point_details, [:principle_id, :point_request_id], unique: true
end
end
5 changes: 5 additions & 0 deletions db/migrate/20200722172424_add_index_to_post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToPost < ActiveRecord::Migration[5.0]
def change
add_index :posts, [:membership_id, :post_type_id], unique: true
end
end
5 changes: 5 additions & 0 deletions db/migrate/20200722173131_add_index_to_point_history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexToPointHistory < ActiveRecord::Migration[5.0]
def change
add_index :point_histories, [:user_id, :semester], unique: true
end
end
34 changes: 33 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,13 @@ CREATE INDEX idx_groups_grp_name ON public.groups USING btree (name);
CREATE INDEX idx_groups_grp_type ON public.groups USING btree (grp_type);


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

CREATE UNIQUE INDEX index_entry_requests_on_evaluation_id_and_user_id ON public.entry_requests USING btree (evaluation_id, user_id);


--
-- Name: index_notifications_on_group_owner_id; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1148,13 +1155,34 @@ CREATE INDEX index_point_detail_comments_on_point_detail_id ON public.point_deta
CREATE INDEX index_point_detail_comments_on_user_id ON public.point_detail_comments USING btree (user_id);


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

CREATE UNIQUE INDEX index_point_details_on_principle_id_and_point_request_id ON public.point_details USING btree (principle_id, point_request_id);


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

CREATE UNIQUE INDEX index_point_histories_on_user_id_and_semester ON public.point_histories USING btree (user_id, semester);


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

CREATE UNIQUE INDEX index_point_requests_on_evaluation_id_and_user_id ON public.point_requests USING btree (evaluation_id, user_id);


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

CREATE UNIQUE INDEX index_posts_on_membership_id_and_post_type_id ON public.posts USING btree (membership_id, post_type_id);


--
-- Name: index_subscriptions_on_key; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -1490,6 +1518,10 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200127202810'),
('20200204185955'),
('20200611204210'),
('20200722112521');
('20200722112521'),
('20200722171738'),
('20200722171937'),
('20200722172424'),
('20200722173131');


0 comments on commit e4d5e49

Please sign in to comment.