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.
3. Changed the value of measured_by_atum_agent in Write Checkpoints to DEFAULT FALSE.
4. Changed the tests to accommodate this change, it has been tested successfully.
  • Loading branch information
ABLL526 committed Feb 21, 2025
1 parent d160b97 commit 9b43abc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion database/src/main/postgres/runs/V0.1.0.32__checkpoints.ddl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CREATE TABLE runs.checkpoints
checkpoint_name TEXT NOT NULL,
process_start_time TIMESTAMP WITH TIME ZONE NOT NULL,
process_end_time TIMESTAMP WITH TIME ZONE,
measured_by_atum_agent BOOLEAN,
measured_by_atum_agent BOOLEAN NOT NULL DEFAULT FALSE,
created_by TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
CONSTRAINT checkpoints_pk PRIMARY KEY (id_checkpoint)
Expand Down
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
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user (Default FALSE)
-- 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_measured_by_atum_agent,
i_by_user
i_by_user,
i_measured_by_atum_agent
) 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[], 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;
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;
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
-- i_measured_by_atum_agent - flag it the checkpoint was measured by Atum or data provided by user (Default FALSE)
-- 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[], 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;
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;
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

0 comments on commit 9b43abc

Please sign in to comment.