media assets: prevent duplicate media assets.
Add a md5 uniqueness constraint on media assets to prevent duplicate assets from being created. This way we can guarantee that there is one active media asset per uploaded file. Also make it so that if two people are uploading the same file at the same time, the file is processed only once.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class AddUniqueMd5ConstraintOnMediaAssets < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_index :media_assets, :md5, name: "index_media_assets_on_md5_and_status", unique: true, where: "status IN (100, 200)"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user