discourse/app/models/post_hotlinked_media.rb
David Taylor 19d2d55011
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.
2022-05-03 15:47:58 +01:00

30 lines
739 B
Ruby

# frozen_string_literal: true
class PostHotlinkedMedia < ActiveRecord::Base
belongs_to :post
belongs_to :upload
enum status: {
downloaded: "downloaded",
too_large: "too_large",
download_failed: "download_failed",
upload_create_failed: "upload_create_failed"
}
end
# == Schema Information
#
# Table name: post_hotlinked_media
#
# id :bigint not null, primary key
# post_id :bigint not null
# url :string not null
# status :enum not null
# upload_id :bigint
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_post_hotlinked_media_on_post_id_and_url_md5 (post_id, md5((url)::text)) UNIQUE
#