uploads: mark old columns as ignored.
Mark old columns as ignored in preparation for dropping them. Make the rating and tag_string nullable so they don't have to be set when creating uploads and can be ignored too.
This commit is contained in:
@@ -5,12 +5,12 @@ class UploadsController < ApplicationController
|
||||
skip_before_action :verify_authenticity_token, only: [:create], if: -> { request.xhr? }
|
||||
|
||||
def new
|
||||
@upload = authorize Upload.new(uploader: CurrentUser.user, uploader_ip_addr: CurrentUser.ip_addr, rating: "q", tag_string: "", source: params[:url], referer_url: params[:ref], **permitted_attributes(Upload))
|
||||
@upload = authorize Upload.new(uploader: CurrentUser.user, uploader_ip_addr: CurrentUser.ip_addr, source: params[:url], referer_url: params[:ref], **permitted_attributes(Upload))
|
||||
respond_with(@upload)
|
||||
end
|
||||
|
||||
def create
|
||||
@upload = authorize Upload.new(uploader: CurrentUser.user, uploader_ip_addr: CurrentUser.ip_addr, rating: "q", tag_string: "", **permitted_attributes(Upload))
|
||||
@upload = authorize Upload.new(uploader: CurrentUser.user, uploader_ip_addr: CurrentUser.ip_addr, **permitted_attributes(Upload))
|
||||
@upload.save
|
||||
respond_with(@upload)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
class Upload < ApplicationRecord
|
||||
extend Memoist
|
||||
|
||||
MAX_VIDEO_DURATION = 140
|
||||
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
|
||||
|
||||
@@ -75,7 +80,7 @@ class Upload < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.search(params)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :source, :referer_url, :uploader, :status, :backtrace, :upload_media_assets, :media_assets)
|
||||
q = search_attributes(params, :id, :created_at, :updated_at, :source, :referer_url, :status, :uploader, :upload_media_assets, :media_assets)
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
@@ -104,7 +109,7 @@ class Upload < ApplicationRecord
|
||||
media_asset = MediaAsset.upload!(media_file)
|
||||
update!(media_assets: [media_asset], status: "completed")
|
||||
rescue Exception => e
|
||||
update!(status: "error: #{e.message}", backtrace: e.backtrace.join("\n"))
|
||||
update!(status: "error: #{e.message}")
|
||||
end
|
||||
|
||||
def self.available_includes
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class DropNotNullConstraintsFromUploads < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
change_column_null(:uploads, :rating, true)
|
||||
change_column_null(:uploads, :tag_string, true)
|
||||
end
|
||||
end
|
||||
@@ -1947,10 +1947,10 @@ CREATE TABLE public.uploads (
|
||||
source text,
|
||||
file_path character varying,
|
||||
content_type character varying,
|
||||
rating character(1) NOT NULL,
|
||||
rating character(1),
|
||||
uploader_id integer NOT NULL,
|
||||
uploader_ip_addr inet NOT NULL,
|
||||
tag_string text NOT NULL,
|
||||
tag_string text,
|
||||
status text DEFAULT 'pending'::text NOT NULL,
|
||||
backtrace text,
|
||||
post_id integer,
|
||||
@@ -5775,6 +5775,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20220110171023'),
|
||||
('20220110171024'),
|
||||
('20220120233850'),
|
||||
('20220124195900');
|
||||
('20220124195900'),
|
||||
('20220203040648');
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ FactoryBot.define do
|
||||
factory(:upload) do
|
||||
uploader factory: :user
|
||||
uploader_ip_addr { "127.0.0.1" }
|
||||
rating { "s" }
|
||||
tag_string { "" }
|
||||
|
||||
status { "pending" }
|
||||
source { "https://cdn.donmai.us/original/d3/4e/d34e4cf0a437a5d65f8e82b7bcd02606.jpg" }
|
||||
|
||||
Reference in New Issue
Block a user