From 85c3b4f2d1aa8b69e3efc92b844d293932b19484 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 18 Oct 2021 00:08:17 -0500 Subject: [PATCH] ugoiras: add md5 column to pixiv_ugoira_frame_data. This is necessary so we can associate ugoira frame data with the media asset instead of with the post. --- ...1018045429_add_md5_to_pixiv_ugoira_frame_data.rb | 10 ++++++++++ db/structure.sql | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20211018045429_add_md5_to_pixiv_ugoira_frame_data.rb diff --git a/db/migrate/20211018045429_add_md5_to_pixiv_ugoira_frame_data.rb b/db/migrate/20211018045429_add_md5_to_pixiv_ugoira_frame_data.rb new file mode 100644 index 000000000..bae0c5fa5 --- /dev/null +++ b/db/migrate/20211018045429_add_md5_to_pixiv_ugoira_frame_data.rb @@ -0,0 +1,10 @@ +class AddMd5ToPixivUgoiraFrameData < ActiveRecord::Migration[6.1] + def change + add_column :pixiv_ugoira_frame_data, :md5, :string, null: true, default: nil + add_index :pixiv_ugoira_frame_data, :md5, unique: true + + up_only do + execute "UPDATE pixiv_ugoira_frame_data u SET md5 = p.md5 FROM posts p WHERE p.id = u.post_id" + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 68fd062eb..8b8a2443e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1329,7 +1329,8 @@ CREATE TABLE public.pixiv_ugoira_frame_data ( id integer NOT NULL, post_id integer NOT NULL, data text NOT NULL, - content_type character varying NOT NULL + content_type character varying NOT NULL, + md5 character varying ); @@ -3897,6 +3898,13 @@ CREATE INDEX index_notes_on_body_tsvector ON public.notes USING gin (to_tsvector CREATE INDEX index_notes_on_post_id ON public.notes USING btree (post_id); +-- +-- Name: index_pixiv_ugoira_frame_data_on_md5; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX index_pixiv_ugoira_frame_data_on_md5 ON public.pixiv_ugoira_frame_data USING btree (md5); + + -- -- Name: index_pixiv_ugoira_frame_data_on_post_id; Type: INDEX; Schema: public; Owner: - -- @@ -5039,6 +5047,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20211011044400'), ('20211013011619'), ('20211014063943'), -('20211015223510'); +('20211015223510'), +('20211018045429');