mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user