Skip to content

Commit befcbe8

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

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
@@ -289,11 +289,16 @@ static MIGRATIONS: &[&str] = &[
289289
CREATE TABLE IF NOT EXISTS collector_config (
290290
id SERIAL PRIMARY KEY,
291291
target TEXT NOT NULL,
292-
name TEXT NOT NULL,
292+
name TEXT NOT NULL UNIQUE,
293293
date_added TIMESTAMPTZ DEFAULT NOW() NOT NULL,
294294
last_heartbeat_at TIMESTAMPTZ,
295295
benchmark_set INTEGER NOT NULL,
296-
is_active BOOLEAN DEFAULT FALSE NOT NULL
296+
is_active BOOLEAN DEFAULT FALSE NOT NULL,
297+
298+
-- Given the current setup, we do not want 2 collectors that are active
299+
-- with the same target using the same benchmark set.
300+
CONSTRAINT collector_config_target_bench_active_uniq
301+
UNIQUE (target, benchmark_set, is_active)
297302
);
298303
"#,
299304
];

0 commit comments

Comments
 (0)