mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-23 18:49:47 -05:00
Fix: Weekly partition dropping (#2066)
* fix: check weekly partitions older than a week old * fix: logic * chore: gen
This commit is contained in:
@@ -17,6 +17,27 @@ BEGIN
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION get_v1_weekly_partitions_before_date(
|
||||
targetTableName text,
|
||||
targetDate date
|
||||
) RETURNS TABLE(partition_name text)
|
||||
LANGUAGE plpgsql AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT
|
||||
inhrelid::regclass::text AS partition_name
|
||||
FROM
|
||||
pg_inherits
|
||||
WHERE
|
||||
inhparent = targetTableName::regclass
|
||||
AND substring(inhrelid::regclass::text, format('%s_(\d{8})', targetTableName)) ~ '^\d{8}'
|
||||
AND (substring(inhrelid::regclass::text, format('%s_(\d{8})', targetTableName))::date) < targetDate
|
||||
AND (substring(inhrelid::regclass::text, format('%s_(\d{8})', targetTableName))::date) < NOW() - INTERVAL '1 week'
|
||||
;
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION create_v1_range_partition(
|
||||
targetTableName text,
|
||||
targetDate date
|
||||
|
||||
Reference in New Issue
Block a user