more insane but more working version of the job queue constraint

This commit is contained in:
Oliver Gorwits
2013-03-25 22:35:11 +00:00
parent cb25216f40
commit 96db66739f
3 changed files with 13 additions and 7 deletions

View File

@@ -54,9 +54,5 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("job"); __PACKAGE__->set_primary_key("job");
__PACKAGE__->add_unique_constraint(
queued_job => [qw/ device action subaction /],
);
# You can replace this text with custom code or comments, and it will be preserved on regeneration # You can replace this text with custom code or comments, and it will be preserved on regeneration
1; 1;

View File

@@ -1,8 +1,12 @@
-- Convert schema '/home/devver/netdisco-ng/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-16-PostgreSQL.sql' to '/home/devver/netdisco-ng/Netdisco/bin/../lib/App/Netdisco/DB/schema_versions/App-Netdisco-DB-17-PostgreSQL.sql':;
BEGIN; BEGIN;
ALTER TABLE admin ADD CONSTRAINT queued_job UNIQUE (device, action, subaction); CREATE UNIQUE INDEX jobs_queued ON admin (
action,
coalesce(subaction, '_x_'),
coalesce(device, '255.255.255.255'),
coalesce(port, '_x_')
) WHERE status = 'queued';
COMMIT; COMMIT;

View File

@@ -21,9 +21,15 @@ CREATE TABLE "admin" (
"log" text, "log" text,
"debug" boolean, "debug" boolean,
PRIMARY KEY ("job"), PRIMARY KEY ("job"),
CONSTRAINT "queued_job" UNIQUE ("device", "action", "subaction")
); );
CREATE UNIQUE INDEX jobs_queued ON admin (
action,
coalesce(subaction, '_x_'),
coalesce(device, '255.255.255.255'),
coalesce(port, '_x_')
) WHERE status = 'queued';
-- --
-- Table: device. -- Table: device.
-- --