From 7c63ac8dbd8d32c289920c572857c45bc726e4b9 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 4 Feb 2022 02:07:07 -0600 Subject: [PATCH] uploads: drop unused columns. --- app/models/upload.rb | 7 ---- ...075610_drop_unused_columns_from_uploads.rb | 24 +++++++++++ db/structure.sql | 41 ++----------------- 3 files changed, 27 insertions(+), 45 deletions(-) create mode 100644 db/migrate/20220204075610_drop_unused_columns_from_uploads.rb diff --git a/app/models/upload.rb b/app/models/upload.rb index e870b0ced..da76e3cee 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -3,13 +3,6 @@ class Upload < ApplicationRecord extend Memoist - self.ignored_columns = %i[ - file_path content_type rating tag_string backtrace post_id md5_confirmation - server parent_id md5 file_ext file_size image_width image_height - artist_commentary_desc artist_commentary_title include_artist_commentary - context translated_commentary_title translated_commentary_desc - ] - attr_accessor :file belongs_to :uploader, class_name: "User" diff --git a/db/migrate/20220204075610_drop_unused_columns_from_uploads.rb b/db/migrate/20220204075610_drop_unused_columns_from_uploads.rb new file mode 100644 index 000000000..5dd26ca94 --- /dev/null +++ b/db/migrate/20220204075610_drop_unused_columns_from_uploads.rb @@ -0,0 +1,24 @@ +class DropUnusedColumnsFromUploads < ActiveRecord::Migration[7.0] + def change + remove_column :uploads, :file_path, :string + remove_column :uploads, :content_type, :string + remove_column :uploads, :rating, :character + remove_column :uploads, :tag_string, :text + remove_column :uploads, :backtrace, :text + remove_column :uploads, :post_id, :integer + remove_column :uploads, :md5_confirmation, :string + remove_column :uploads, :server, :text + remove_column :uploads, :parent_id, :integer + remove_column :uploads, :md5, :string + remove_column :uploads, :file_ext, :string + remove_column :uploads, :file_size, :integer + remove_column :uploads, :image_width, :integer + remove_column :uploads, :image_height, :integer + remove_column :uploads, :artist_commentary_desc, :text + remove_column :uploads, :artist_commentary_title, :text + remove_column :uploads, :include_artist_commentary, :boolean + remove_column :uploads, :context, :text + remove_column :uploads, :translated_commentary_title, :text + remove_column :uploads, :translated_commentary_desc, :text + end +end diff --git a/db/structure.sql b/db/structure.sql index 5b5bfc48a..33dbd4943 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1945,32 +1945,12 @@ ALTER SEQUENCE public.upload_media_assets_id_seq OWNED BY public.upload_media_as CREATE TABLE public.uploads ( id integer NOT NULL, source text, - file_path character varying, - content_type character varying, - rating character(1), uploader_id integer NOT NULL, uploader_ip_addr inet NOT NULL, - tag_string text, status text DEFAULT 'pending'::text NOT NULL, - backtrace text, - post_id integer, - md5_confirmation character varying, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL, - server text, - parent_id integer, - md5 character varying, - file_ext character varying, - file_size integer, - image_width integer, - image_height integer, - artist_commentary_desc text, - artist_commentary_title text, - include_artist_commentary boolean, - context text, - referer_url text, - translated_commentary_title text DEFAULT ''::text NOT NULL, - translated_commentary_desc text DEFAULT ''::text NOT NULL + referer_url text ); @@ -4851,22 +4831,6 @@ ALTER TABLE ONLY public.comment_votes ADD CONSTRAINT fk_rails_0873e64a40 FOREIGN KEY (user_id) REFERENCES public.users(id) DEFERRABLE INITIALLY DEFERRED; --- --- Name: uploads fk_rails_0e5f710d62; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.uploads - ADD CONSTRAINT fk_rails_0e5f710d62 FOREIGN KEY (parent_id) REFERENCES public.posts(id) DEFERRABLE INITIALLY DEFERRED; - - --- --- Name: uploads fk_rails_127111e6ac; Type: FK CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.uploads - ADD CONSTRAINT fk_rails_127111e6ac FOREIGN KEY (post_id) REFERENCES public.posts(id) DEFERRABLE INITIALLY DEFERRED NOT VALID; - - -- -- Name: upload_media_assets fk_rails_171271f781; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5776,6 +5740,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220110171024'), ('20220120233850'), ('20220124195900'), -('20220203040648'); +('20220203040648'), +('20220204075610');