Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle ingestion vs export raster jobs with nullish identifier #39

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/DAL/migration/FullSchema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ CREATE TABLE "Job"
"pendingTasks" int NOT NULL DEFAULT 0,
"inProgressTasks" int NOT NULL DEFAULT 0,
"abortedTasks" int NOT NULL DEFAULT 0,
"additionalIdentifiers" text COLLATE pg_catalog."default" NOT NULL DEFAULT ''::text,
"additionalIdentifiers" text COLLATE pg_catalog."default",
"domain" text COLLATE pg_catalog."default" NOT NULL DEFAULT ''::text,
CONSTRAINT "PK_job_id" PRIMARY KEY (id),
CONSTRAINT "UQ_uniqueness_on_active_tasks" EXCLUDE ("resourceId" with =, "version" with =, "type" with =, "additionalIdentifiers" with =) WHERE (status = 'Pending' OR status = 'In-Progress')
CONSTRAINT "UQ_uniqueness_on_active_tasks" EXCLUDE ("resourceId" with =, "version" with =, "type" with =, "additionalIdentifiers" with =) WHERE ((status = 'Pending' OR status = 'In-Progress') AND ("additionalIdentifiers" IS NOT NULL)),
CONSTRAINT "UQ_uniqueness_on_active_tasks_no_additional_identifier" EXCLUDE ("resourceId" with =, "version" with =, "type" with =) WHERE ((status = 'Pending' OR status = 'In-Progress') AND ("additionalIdentifiers" IS NULL))
);

CREATE INDEX "jobCleanedIndex"
Expand Down
11 changes: 0 additions & 11 deletions src/DAL/migration/v.2.6.1.sql

This file was deleted.

29 changes: 29 additions & 0 deletions src/DAL/migration/v.2.6.2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SET search_path TO "JobManager", public; -- CHANGE SCHEMA NAME TO MATCH ENVIRONMENT

WITH marked_for_delete AS (
SELECT unnest((array_agg(id))[2:]) id
FROM "Job"
WHERE ("additionalIdentifiers" IS NULL)
asafMasa marked this conversation as resolved.
Show resolved Hide resolved
GROUP BY "resourceId","version","type"
), deleteTasks as (
DELETE FROM "Task"
USING marked_for_delete m
WHERE "Task"."jobId" = m.id
)
DELETE FROM "Job"
USING marked_for_delete m
WHERE "Job".id = m.id;

-- Alter the table to add the modified and new constraints

ALTER TABLE "Job"
DROP CONSTRAINT IF EXISTS "UQ_uniqueness_on_active_tasks";

ALTER TABLE "Job"
ADD CONSTRAINT "UQ_uniqueness_on_active_tasks" EXCLUDE ("resourceId" with =, "version" with =, "type" with =, "additionalIdentifiers" with =) WHERE ((status = 'Pending' OR status = 'In-Progress') AND ("additionalIdentifiers" IS NOT NULL));

ALTER TABLE "Job"
DROP CONSTRAINT IF EXISTS "UQ_uniqueness_on_active_tasks_no_additional_identifier";

ALTER TABLE "Job"
ADD CONSTRAINT "UQ_uniqueness_on_active_tasks_no_additional_identifier" EXCLUDE ("resourceId" with =, "version" with =, "type" with =) WHERE ((status = 'Pending' OR status = 'In-Progress') AND ("additionalIdentifiers" IS NULL));
Loading