mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 17:36:27 +08:00
23 lines
648 B
Ruby
23 lines
648 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class FixPostHotlinkedMediaIndex < ActiveRecord::Migration[6.1]
|
||
|
disable_ddl_transaction!
|
||
|
|
||
|
def up
|
||
|
execute <<~SQL
|
||
|
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS index_post_hotlinked_media_on_post_id_and_url_md5
|
||
|
ON post_hotlinked_media (post_id, md5(url));
|
||
|
SQL
|
||
|
|
||
|
# Failed index introduced in 20220428094026_create_post_hotlinked_media. On some installations it succeeded,
|
||
|
# so we need to clean it up.
|
||
|
execute <<~SQL
|
||
|
DROP INDEX CONCURRENTLY IF EXISTS index_post_hotlinked_media_on_post_id_and_url;
|
||
|
SQL
|
||
|
end
|
||
|
|
||
|
def down
|
||
|
raise ActiveRecord::IrreversibleMigration
|
||
|
end
|
||
|
end
|