mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Change upload verified column to be integer (#10643)
Per review https://review.discourse.org/t/dev-add-verified-to-uploads-and-fill-in-s3-inventory-10406/14180 Change the verified column for Upload to a verified_status integer column, to avoid having NULL as a weird implicit status.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ChangeUploadsVerifiedToInteger < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
add_column :uploads, :verification_status, :integer, null: false, default: 1
|
||||
Migration::ColumnDropper.mark_readonly(:uploads, :verified)
|
||||
|
||||
DB.exec(
|
||||
<<~SQL
|
||||
UPDATE uploads SET verification_status = CASE WHEN
|
||||
verified THEN 2
|
||||
WHEN NOT verified THEN 3
|
||||
END
|
||||
SQL
|
||||
)
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :uploads, :verification_status
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToUploadsVerificationStatus < ActiveRecord::Migration[6.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
execute <<~SQL
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS
|
||||
idx_uploads_on_verification_status ON uploads USING btree (verification_status)
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
execute "DROP INDEX IF EXISTS idx_uploads_on_verification_status"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user