Skip to content

Commit 4efc625

Browse files
committed
Add unique constraint on (target, benchmark_set, is_active)
1 parent d5ab083 commit 4efc625

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

database/src/pool/postgres.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,16 @@ static MIGRATIONS: &[&str] = &[
305305
CREATE TABLE IF NOT EXISTS collector_config (
306306
id SERIAL PRIMARY KEY,
307307
target TEXT NOT NULL,
308-
name TEXT NOT NULL,
308+
name TEXT NOT NULL UNIQUE,
309309
date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL,
310310
last_heartbeat_at TIMESTAMPTZ,
311311
benchmark_set INTEGER NOT NULL,
312-
is_active BOOLEAN DEFAULT FALSE NOT NULL
312+
is_active BOOLEAN DEFAULT FALSE NOT NULL,
313+
314+
-- Given the current setup, we do not want 2 collectors that are active
315+
-- with the same target using the same benchmark set.
316+
CONSTRAINT collector_config_target_bench_active_uniq
317+
UNIQUE (target, benchmark_set, is_active)
313318
);
314319
"#,
315320
];

0 commit comments

Comments
 (0)