Skip to content

Commit adc0417

Browse files
committed
Add unique constraint on (target, benchmark_set, is_active)
1 parent 23a7b02 commit adc0417

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
@@ -310,11 +310,16 @@ static MIGRATIONS: &[&str] = &[
310310
CREATE TABLE IF NOT EXISTS collector_config (
311311
id SERIAL PRIMARY KEY,
312312
target TEXT NOT NULL,
313-
name TEXT NOT NULL,
313+
name TEXT NOT NULL UNIQUE,
314314
date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL,
315315
last_heartbeat_at TIMESTAMPTZ,
316316
benchmark_set INTEGER NOT NULL,
317-
is_active BOOLEAN DEFAULT FALSE NOT NULL
317+
is_active BOOLEAN DEFAULT FALSE NOT NULL,
318+
319+
-- Given the current setup, we do not want 2 collectors that are active
320+
-- with the same target using the same benchmark set.
321+
CONSTRAINT collector_config_target_bench_active_uniq
322+
UNIQUE (target, benchmark_set, is_active)
318323
);
319324
"#,
320325
];

0 commit comments

Comments
 (0)