mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 11:06:43 +08:00
19d2d55011
On some installations, this would fail with 'index row size exceeds btree version 4 maximum'. This commit replaces the (post_id, url)` index with a `(post_id, md5(url))` index, which is much more space efficient.
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
|