Skip to content

Commit e8b9121

Browse files
committed
Add unique constraint on (target, benchmark_set, is_active)
1 parent ef42ae2 commit e8b9121

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
@@ -313,11 +313,16 @@ static MIGRATIONS: &[&str] = &[
313313
CREATE TABLE IF NOT EXISTS collector_config (
314314
id SERIAL PRIMARY KEY,
315315
target TEXT NOT NULL,
316-
name TEXT NOT NULL,
316+
name TEXT NOT NULL UNIQUE,
317317
date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL,
318318
last_heartbeat_at TIMESTAMPTZ,
319319
benchmark_set INTEGER NOT NULL,
320-
is_active BOOLEAN DEFAULT FALSE NOT NULL
320+
is_active BOOLEAN DEFAULT FALSE NOT NULL,
321+
322+
-- Given the current setup, we do not want 2 collectors that are active
323+
-- with the same target using the same benchmark set.
324+
CONSTRAINT collector_config_target_bench_active_uniq
325+
UNIQUE (target, benchmark_set, is_active)
321326
);
322327
"#,
323328
];

0 commit comments

Comments
 (0)