diff --git a/app/models/upload.rb b/app/models/upload.rb index 99d811ddd7..ba6ab75225 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -3,7 +3,7 @@ # Table name: uploads # # id :bigint not null, primary key -# filename :string default(""), not null +# filename :string not null # malware_scan_result :string default("pending"), not null # translation :boolean not null # created_at :datetime not null diff --git a/db/migrate/20240410151207_change_upload_filename_default.rb b/db/migrate/20240410151207_change_upload_filename_default.rb new file mode 100644 index 0000000000..5bbfa1c01a --- /dev/null +++ b/db/migrate/20240410151207_change_upload_filename_default.rb @@ -0,0 +1,5 @@ +class ChangeUploadFilenameDefault < ActiveRecord::Migration[7.1] + def change + change_column_default :uploads, :filename, from: "", to: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index f6626d5cc2..133d9394f3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_04_10_150439) do +ActiveRecord::Schema[7.1].define(version: 2024_04_10_151207) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -533,7 +533,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "malware_scan_result", default: "pending", null: false - t.string "filename", default: "", null: false + t.string "filename", null: false t.index ["document_id"], name: "index_uploads_on_document_id" end diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake deleted file mode 100644 index 8713e8fc6d..0000000000 --- a/lib/tasks/uploads.rake +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -namespace :uploads do - desc "Resend blob data for uploads that have a pending malware scan result" - task update_filename: :environment do - Upload - .where(filename: "") - .with_attached_attachment - .find_each do |upload| - upload.update!(filename: upload.attachment.filename || "unknown") - end - end -end diff --git a/spec/factories/uploads.rb b/spec/factories/uploads.rb index 7291738236..016b1fe764 100644 --- a/spec/factories/uploads.rb +++ b/spec/factories/uploads.rb @@ -3,7 +3,7 @@ # Table name: uploads # # id :bigint not null, primary key -# filename :string default(""), not null +# filename :string not null # malware_scan_result :string default("pending"), not null # translation :boolean not null # created_at :datetime not null diff --git a/spec/fixtures/files/translation_upload.pdf b/spec/fixtures/files/translation_upload.pdf deleted file mode 100644 index 232fb40e3e..0000000000 Binary files a/spec/fixtures/files/translation_upload.pdf and /dev/null differ diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb index 9e4106ae9e..f1d067c4b9 100644 --- a/spec/models/upload_spec.rb +++ b/spec/models/upload_spec.rb @@ -3,7 +3,7 @@ # Table name: uploads # # id :bigint not null, primary key -# filename :string default(""), not null +# filename :string not null # malware_scan_result :string default("pending"), not null # translation :boolean not null # created_at :datetime not null