From 90268757768039faa78058cbcd45dcf0043e6a59 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 25 Sep 2022 00:03:52 -0500 Subject: [PATCH] db: add subject_id, subject_type columns to mod_actions. The subject of the mod action is the post, user, or other object the modaction is for. --- ...220925045236_add_subject_to_mod_actions.rb | 9 ++++++++ db/structure.sql | 21 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20220925045236_add_subject_to_mod_actions.rb diff --git a/db/migrate/20220925045236_add_subject_to_mod_actions.rb b/db/migrate/20220925045236_add_subject_to_mod_actions.rb new file mode 100644 index 000000000..770e85ee7 --- /dev/null +++ b/db/migrate/20220925045236_add_subject_to_mod_actions.rb @@ -0,0 +1,9 @@ +class AddSubjectToModActions < ActiveRecord::Migration[7.0] + def change + add_column :mod_actions, :subject_type, :string, null: true + add_column :mod_actions, :subject_id, :integer, null: true + + add_index :mod_actions, :subject_type + add_index :mod_actions, :subject_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 895eba1cb..763fa35e4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -993,7 +993,9 @@ CREATE TABLE public.mod_actions ( description text NOT NULL, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, - category integer NOT NULL + category integer NOT NULL, + subject_type character varying, + subject_id integer ); @@ -4396,6 +4398,20 @@ CREATE INDEX index_mod_actions_on_creator_id_and_created_at ON public.mod_action CREATE INDEX index_mod_actions_on_description ON public.mod_actions USING gin (description public.gin_trgm_ops); +-- +-- Name: index_mod_actions_on_subject_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mod_actions_on_subject_id ON public.mod_actions USING btree (subject_id); + + +-- +-- Name: index_mod_actions_on_subject_type; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mod_actions_on_subject_type ON public.mod_actions USING btree (subject_type); + + -- -- Name: index_mod_actions_on_to_tsvector_pg_catalog_english_description; Type: INDEX; Schema: public; Owner: - -- @@ -6722,6 +6738,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220921022408'), ('20220922014326'), ('20220923010905'), -('20220924092056'); +('20220924092056'), +('20220925045236');