diff --git a/internal/database/migrations/20240615110350_constraint.sql b/internal/database/migrations/20240615110350_constraint.sql new file mode 100644 index 0000000..262ca51 --- /dev/null +++ b/internal/database/migrations/20240615110350_constraint.sql @@ -0,0 +1,7 @@ +-- +goose Up +-- +goose StatementBegin +DROP INDEX IF EXISTS teldrive.unique_file; +CREATE UNIQUE INDEX IF NOT EXISTS unique_file ON teldrive.files USING btree (name, parent_id, user_id,size) WHERE (status = 'active'::text AND type='file'::text); +CREATE UNIQUE INDEX IF NOT EXISTS unique_folder ON teldrive.files USING btree (name, parent_id, user_id) WHERE (type='folder'::text); + +-- +goose StatementEnd