Add rate limiting to user friendships

This commit is contained in:
Tom Hughes 2021-05-11 12:02:05 +01:00
parent 4d164df5b8
commit 84c601460f
6 changed files with 33 additions and 8 deletions

View file

@ -0,0 +1,9 @@
class AddTimeToFriendships < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def change
add_column :friends, :created_at, :datetime
add_index :friends, [:user_id, :created_at], :algorithm => :concurrently
remove_index :friends, :column => :user_id, :name => "friends_user_id_idx"
end
end

View file

@ -720,7 +720,8 @@ CREATE TABLE public.diary_entry_subscriptions (
CREATE TABLE public.friends (
id bigint NOT NULL,
user_id bigint NOT NULL,
friend_user_id bigint NOT NULL
friend_user_id bigint NOT NULL,
created_at timestamp without time zone
);
@ -2146,13 +2147,6 @@ CREATE INDEX diary_entry_language_code_created_at_index ON public.diary_entries
CREATE INDEX diary_entry_user_id_created_at_index ON public.diary_entries USING btree (user_id, created_at);
--
-- Name: friends_user_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX friends_user_id_idx ON public.friends USING btree (user_id);
--
-- Name: gpx_file_tags_gpxid_idx; Type: INDEX; Schema: public; Owner: -
--
@ -2279,6 +2273,13 @@ CREATE INDEX index_client_applications_on_user_id ON public.client_applications
CREATE INDEX index_diary_entry_subscriptions_on_diary_entry_id ON public.diary_entry_subscriptions USING btree (diary_entry_id);
--
-- Name: index_friends_on_user_id_and_created_at; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_friends_on_user_id_and_created_at ON public.friends USING btree (user_id, created_at);
--
-- Name: index_issue_comments_on_issue_id; Type: INDEX; Schema: public; Owner: -
--
@ -3123,6 +3124,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20201006213836'),
('20201006220807'),
('20201214144017'),
('20210511104518'),
('21'),
('22'),
('23'),