Skip to content

Commit

Permalink
Change checkpoint's table DDL, set column measured_by_atum_agent to h…
Browse files Browse the repository at this point in the history
…ave NOT NULL constraint with DEFAULT FALSE #242

Made changes:
1. Changed the value of measured_by_atum_agent in Checkpoints DDL to NOT NULL.
2. Changed the value of measured_by_atum_agent in Checkpoints DDL to DEFAULT FALSE as according to the issue request.
  • Loading branch information
ABLL526 committed Feb 25, 2025
1 parent b02fdc0 commit 97b203e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions database/src/main/postgres/runs/V0.2.0.14__write_checkpoint.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ CREATE OR REPLACE FUNCTION runs.write_checkpoint(
IN i_process_start_time TIMESTAMP WITH TIME ZONE,
IN i_process_end_time TIMESTAMP WITH TIME ZONE,
IN i_measurements JSONB[],
in i_measured_by_atum_agent BOOLEAN,
IN i_by_user TEXT,
IN i_measured_by_atum_agent BOOLEAN DEFAULT FALSE,
OUT status INTEGER,
OUT status_text TEXT
) RETURNS record AS
Expand All @@ -48,7 +48,7 @@ $$
-- whatever here
-- }
-- }
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user (Default FALSE)
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user
-- i_by_user - user behind the change
--
-- Returns:
Expand Down Expand Up @@ -81,8 +81,8 @@ BEGIN
i_process_start_time,
i_process_end_time,
i_measurements,
i_by_user,
i_measured_by_atum_agent
i_measured_by_atum_agent,
i_by_user
) WC
INTO status, status_text;

Expand All @@ -91,5 +91,5 @@ END;
$$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;

ALTER FUNCTION runs.write_checkpoint(JSONB, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], TEXT, BOOLEAN) OWNER TO atum_owner;
GRANT EXECUTE ON FUNCTION runs.write_checkpoint(JSONB, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], TEXT, BOOLEAN) TO atum_user;
ALTER FUNCTION runs.write_checkpoint(JSONB, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], BOOLEAN, TEXT) OWNER TO atum_owner;
GRANT EXECUTE ON FUNCTION runs.write_checkpoint(JSONB, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], BOOLEAN, TEXT) TO atum_user;
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ CREATE OR REPLACE FUNCTION runs.write_checkpoint(
IN i_process_start_time TIMESTAMP WITH TIME ZONE,
IN i_process_end_time TIMESTAMP WITH TIME ZONE,
IN i_measurements JSONB[],
IN i_measured_by_atum_agent BOOLEAN,
IN i_by_user TEXT,
IN i_measured_by_atum_agent BOOLEAN DEFAULT FALSE,
OUT status INTEGER,
OUT status_text TEXT
) RETURNS record AS
Expand All @@ -47,7 +47,7 @@ $$
-- whatever here
-- }
-- }
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user (Default FALSE)
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user
-- i_by_user - user behind the change
--
-- Returns:
Expand Down Expand Up @@ -105,5 +105,5 @@ END;
$$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER;

ALTER FUNCTION runs.write_checkpoint(BIGINT, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], TEXT, BOOLEAN) OWNER TO atum_owner;
GRANT EXECUTE ON FUNCTION runs.write_checkpoint(BIGINT, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], TEXT, BOOLEAN) TO atum_user;
ALTER FUNCTION runs.write_checkpoint(BIGINT, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], BOOLEAN, TEXT) OWNER TO atum_owner;
GRANT EXECUTE ON FUNCTION runs.write_checkpoint(BIGINT, UUID, TEXT, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, JSONB[], BOOLEAN, TEXT) TO atum_user;
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WriteCheckpointIntegrationTests extends DBTestSuite {
.setParam("i_process_start_time", startTime)
.setParam("i_process_end_time", endTime)
.setParam("i_measurements", CustomDBType(measurements, "JSONB[]"))
//.setParam("i_measured_by_atum_agent", false)
.setParam("i_measured_by_atum_agent", false)
.setParam("i_by_user", user)
.execute { queryResult =>
assert(queryResult.hasNext)
Expand Down Expand Up @@ -235,7 +235,7 @@ class WriteCheckpointIntegrationTests extends DBTestSuite {
.add("checkpoint_name", "I came before")
.add("process_start_time", now())
.add("process_end_time", now())
//.add("measured_by_atum_agent", false)
.add("measured_by_atum_agent", false)
.add("created_by", origAuthor)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class WriteCheckpointOverloadedIntegrationTests extends DBTestSuite {
.setParam("i_process_start_time", startTime)
.setParam("i_process_end_time", endTime)
.setParam("i_measurements", CustomDBType(measurements, "JSONB[]"))
//.setParam("i_measured_by_atum_agent", false)
.setParam("i_measured_by_atum_agent", false)
.setParam("i_by_user", user)
.execute { queryResult =>
assert(queryResult.hasNext)
Expand Down Expand Up @@ -237,7 +237,7 @@ class WriteCheckpointOverloadedIntegrationTests extends DBTestSuite {
.add("checkpoint_name", "I came before")
.add("process_start_time", now())
.add("process_end_time", now())
//.add("measured_by_atum_agent", false)
.add("measured_by_atum_agent", false)
.add("created_by", origAuthor)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class WriteCheckpoint(implicit schema: DBSchema, dbEngine: DoobieEngine[Task])
fr"${values.processStartTime}",
fr"${values.processEndTime}",
fr"${values.measurements.toList.map(_.asJson)}",
fr"${values.author}",
fr"${values.measuredByAtumAgent}"
fr"${values.measuredByAtumAgent}",
fr"${values.author}"
)
)
with StandardStatusHandling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class WriteCheckpointV2(implicit schema: DBSchema, dbEngine: DoobieEngine[Task])
fr"${args.checkpointV2DTO.processStartTime}",
fr"${args.checkpointV2DTO.processEndTime}",
fr"${args.checkpointV2DTO.measurements.toList.map(_.asJson)}",
fr"${args.checkpointV2DTO.author}",
fr"${args.checkpointV2DTO.measuredByAtumAgent}"
fr"${args.checkpointV2DTO.measuredByAtumAgent}",
fr"${args.checkpointV2DTO.author}"
),
Some("write_checkpoint")
)
Expand Down

0 comments on commit 97b203e

Please sign in to comment.