replacements: add media_asset_id, old_media_asset_id columns.

Add media_asset_id and old_media_asset_id columns for associating replacements with media assets.
This way we can easily tell which replacements don't have a media asset (with the md5 alone we can't
tell whether the media asset actually exists).
This commit is contained in:
evazion
2022-11-08 23:39:01 -06:00
parent 83d14a281f
commit b472ae5c87
2 changed files with 58 additions and 2 deletions

View File

@@ -1434,7 +1434,9 @@ CREATE TABLE public.post_replacements (
file_size integer,
image_width integer,
image_height integer,
md5 character varying
md5 character varying,
media_asset_id integer,
old_media_asset_id integer
);
@@ -4954,6 +4956,34 @@ CREATE INDEX index_post_replacements_on_creator_id ON public.post_replacements U
CREATE INDEX index_post_replacements_on_creator_id_and_created_at ON public.post_replacements USING btree (creator_id, created_at);
--
-- Name: index_post_replacements_on_md5; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_replacements_on_md5 ON public.post_replacements USING btree (md5);
--
-- Name: index_post_replacements_on_media_asset_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_replacements_on_media_asset_id ON public.post_replacements USING btree (media_asset_id);
--
-- Name: index_post_replacements_on_old_md5; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_replacements_on_old_md5 ON public.post_replacements USING btree (old_md5);
--
-- Name: index_post_replacements_on_old_media_asset_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_post_replacements_on_old_media_asset_id ON public.post_replacements USING btree (old_media_asset_id);
--
-- Name: index_post_replacements_on_post_id; Type: INDEX; Schema: public; Owner: -
--
@@ -6045,6 +6075,14 @@ ALTER TABLE ONLY public.comments
ADD CONSTRAINT fk_rails_2fd19c0db7 FOREIGN KEY (post_id) REFERENCES public.posts(id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: post_replacements fk_rails_317818fc2f; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.post_replacements
ADD CONSTRAINT fk_rails_317818fc2f FOREIGN KEY (media_asset_id) REFERENCES public.media_assets(id);
--
-- Name: api_keys fk_rails_32c28d0dc2; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -6165,6 +6203,14 @@ ALTER TABLE ONLY public.news_updates
ADD CONSTRAINT fk_rails_502e0a41d1 FOREIGN KEY (updater_id) REFERENCES public.users(id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: post_replacements fk_rails_5077102432; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.post_replacements
ADD CONSTRAINT fk_rails_5077102432 FOREIGN KEY (old_media_asset_id) REFERENCES public.media_assets(id);
--
-- Name: forum_topics fk_rails_53d4e863cd; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -6910,6 +6956,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20221026084655'),
('20221026084656'),
('20221027000931'),
('20221106062419');
('20221106062419'),
('20221109052923');