FIX: Ensure post_hotlinked_media index does not exceed size limit (#16609)

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.
This commit is contained in:
David Taylor
2022-05-03 15:47:58 +01:00
committed by GitHub
parent 51e29d3ca8
commit 19d2d55011
3 changed files with 30 additions and 2 deletions

View File

@@ -22,9 +22,15 @@ class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
t.bigint :upload_id
t.timestamps
t.index [:post_id, :url], unique: true
# Failed on some installations due to index size. Repaired in 20220428094027
# t.index [:post_id, :url], unique: true
end
execute <<~SQL
CREATE UNIQUE INDEX index_post_hotlinked_media_on_post_id_and_url_md5
ON post_hotlinked_media (post_id, md5(url));
SQL
reversible do |dir|
dir.up do
execute <<~SQL