Replace the unique constraint on library_item table with a unique index of userId and md5 hashed original url
This commit is contained in:
10
packages/db/migrations/0127.do.replace_unique_index_on_library_item.sql
Executable file
10
packages/db/migrations/0127.do.replace_unique_index_on_library_item.sql
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
-- Type: DO
|
||||||
|
-- Name: replace_unique_index_on_library_item
|
||||||
|
-- Description: Create a unique index of MD5 hashed url and userId on library item table
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE omnivore.library_item DROP CONSTRAINT IF EXISTS library_item_user_id_original_url_key;
|
||||||
|
CREATE UNIQUE INDEX library_item_user_id_hashed_original_url_key ON omnivore.library_item (user_id, md5(original_url));
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
10
packages/db/migrations/0127.undo.replace_unique_index_on_library_item.sql
Executable file
10
packages/db/migrations/0127.undo.replace_unique_index_on_library_item.sql
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
-- Type: UNDO
|
||||||
|
-- Name: replace_unique_index_on_library_item
|
||||||
|
-- Description: Create a unique index of MD5 hashed url and userId on library item table
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
DROP INDEX IF EXISTS omnivore.library_item_user_id_hashed_original_url_key;
|
||||||
|
ALTER TABLE omnivore.library_item ADD CONSTRAINT library_item_user_id_original_url_key UNIQUE (user_id, original_url);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Reference in New Issue
Block a user