Files
coder/coderd/database/migrations/000380_task_name_unique.up.sql
T
Mathias Fredriksson 5dc57da6b4 fix(coderd/database): ensure task name uniqueness (#20236)
This change ensures task names are unique per user the same way we do
for workspaces. This ensures we don't create tasks that are impossible
to start due to another task being named the same creating a workspace
name conflict.

Updates coder/internal#948
Supersedes coder/coder#20212
2025-10-13 12:42:38 +03:00

3 lines
225 B
SQL

CREATE UNIQUE INDEX IF NOT EXISTS tasks_owner_id_name_unique_idx ON tasks (owner_id, LOWER(name)) WHERE deleted_at IS NULL;
COMMENT ON INDEX tasks_owner_id_name_unique_idx IS 'Index to ensure uniqueness for task owner/name';