Skip to content

Commit

Permalink
rename validate timezone function
Browse files Browse the repository at this point in the history
  • Loading branch information
David Micallef committed Jun 15, 2024
1 parent 1724b32 commit 807b5bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/pgengine/sql/ddl.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE FUNCTION timetable.is_pg_timetable_name(TEXT) RETURNS BOOLEAN AS
CREATE FUNCTION timetable.is_valid_timezone(TEXT) RETURNS BOOLEAN AS
$$
SELECT $1 IN (SELECT name FROM pg_timezone_names());
$$ LANGUAGE sql;
Expand All @@ -15,7 +15,7 @@ CREATE TABLE timetable.chain (
client_name TEXT,
on_error TEXT,
run_at_timezone TEXT DEFAULT current_setting('timezone')
constraint valid_run_at_timezone check (timetable.is_pg_timetable_name(run_at_timezone))
constraint valid_run_at_timezone check (timetable.is_valid_timezone(run_at_timezone))
);

COMMENT ON TABLE timetable.chain IS
Expand Down
6 changes: 3 additions & 3 deletions internal/pgengine/sql/migrations/00645.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ CREATE OR REPLACE FUNCTION timetable.is_cron_in_time(
timetable.cron_split_to_arrays(run_at) a
$$ LANGUAGE SQL;

DROP FUNCTION IF EXISTS timetable.is_pg_timetable_name;
CREATE FUNCTION timetable.is_pg_timetable_name(TEXT) RETURNS BOOLEAN AS
DROP FUNCTION IF EXISTS timetable.is_valid_timezone;
CREATE FUNCTION timetable.is_valid_timezone(TEXT) RETURNS BOOLEAN AS
$$
SELECT $1 IN (SELECT name FROM pg_timezone_names());
$$ LANGUAGE sql;

ALTER TABLE timetable.chain
ADD COLUMN run_at_timezone TEXT DEFAULT current_setting('timezone') NOT NULL,
ADD CONSTRAINT valid_run_at_timezone CHECK (timetable.is_pg_timetable_name(run_at_timezone));
ADD CONSTRAINT valid_run_at_timezone CHECK (timetable.is_valid_timezone(run_at_timezone));

DROP FUNCTION IF EXISTS timetable.add_job;
CREATE OR REPLACE FUNCTION timetable.add_job(
Expand Down

0 comments on commit 807b5bd

Please sign in to comment.