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:
@@ -3779,6 +3779,13 @@ CREATE INDEX index_media_assets_on_image_width ON public.media_assets USING btre
|
||||
CREATE INDEX index_media_assets_on_md5 ON public.media_assets USING btree (md5);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_md5_and_status; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE UNIQUE INDEX index_media_assets_on_md5_and_status ON public.media_assets USING btree (md5) WHERE (status = ANY (ARRAY[100, 200]));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_media_assets_on_status; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -5049,6 +5056,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20211014063943'),
|
||||
('20211015223510'),
|
||||
('20211018045429'),
|
||||
('20211018062916');
|
||||
('20211018062916'),
|
||||
('20211023225730');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user