Skip to content

Commit

Permalink
add made_current_at field to job_versions
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Leszczynski <leszczynski.pawel@gmail.com>
  • Loading branch information
pawel-big-lebowski committed Dec 13, 2023
1 parent 7386a87 commit a8cdbe0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/marquez/db/JobVersionDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ ExtendedJobVersionRow upsertJobVersion(
@SqlUpdate(
"""
INSERT INTO job_versions_io_mapping (
job_version_uuid, dataset_uuid, io_type, job_uuid, job_symlink_target_uuid, is_current_job_version)
VALUES (:jobVersionUuid, :datasetUuid, :ioType, :jobUuid, :symlinkTargetJobUuid, TRUE)
job_version_uuid, dataset_uuid, io_type, job_uuid, job_symlink_target_uuid, is_current_job_version, made_current_at)
VALUES (:jobVersionUuid, :datasetUuid, :ioType, :jobUuid, :symlinkTargetJobUuid, TRUE, NOW())
ON CONFLICT (job_version_uuid, dataset_uuid, io_type, job_uuid) DO NOTHING
""")
void upsertCurrentInputOrOutputDatasetFor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class V67_2_JobVersionsIOMappingBackfillJob implements JavaMigration {
SET
job_uuid = j.uuid,
job_symlink_target_uuid = j.symlink_target_uuid,
is_current_job_version = (jv.uuid = j.current_version_uuid)::BOOLEAN
is_current_job_version = (jv.uuid = j.current_version_uuid)::BOOLEAN,
made_current_at = NOW()
FROM job_versions jv
INNER JOIN jobs_view j ON j.uuid = jv.job_uuid
WHERE jv.uuid = job_versions_io_mapping.job_version_uuid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ALTER TABLE job_versions_io_mapping ADD COLUMN job_uuid uuid REFERENCES jobs(uuid) ON DELETE CASCADE;
ALTER TABLE job_versions_io_mapping ADD COLUMN job_symlink_target_uuid uuid REFERENCES jobs(uuid) ON DELETE CASCADE;
ALTER TABLE job_versions_io_mapping ADD COLUMN is_current_job_version boolean DEFAULT FALSE;
ALTER TABLE job_versions_io_mapping ADD COLUMN made_current_at TIMESTAMP;

-- To add job_uuid to the unique constraint, we first drop the primary key, then recreate it; note given that job_version_uuid can be NULL, we need to check that job_version_uuid != NULL before inserting (duplicate columns otherwise)
ALTER TABLE job_versions_io_mapping DROP CONSTRAINT job_versions_io_mapping_pkey;
Expand Down

0 comments on commit a8cdbe0

Please sign in to comment.