diff --git a/sql/updates/2.14.2--2.15.0.sql b/sql/updates/2.14.2--2.15.0.sql index 3b5383f94da..e396c55b2c2 100644 --- a/sql/updates/2.14.2--2.15.0.sql +++ b/sql/updates/2.14.2--2.15.0.sql @@ -427,23 +427,3 @@ DROP FUNCTION IF EXISTS _timescaledb_functions.policy_job_error_retention_check( -- -- END bgw_job_stat_history -- - --- Migrate existing CAggs using time_bucket_ng to time_bucket -CREATE PROCEDURE _timescaledb_functions.cagg_migrate_to_time_bucket(cagg REGCLASS) - AS '@MODULE_PATHNAME@', 'ts_continuous_agg_migrate_to_time_bucket' LANGUAGE C; - -DO $$ -DECLARE - cagg_name regclass; -BEGIN - FOR cagg_name IN - SELECT pg_catalog.format('%I.%I', user_view_schema, user_view_name)::regclass - FROM _timescaledb_catalog.continuous_agg cagg - JOIN _timescaledb_catalog.continuous_aggs_bucket_function AS bf ON (cagg.mat_hypertable_id = bf.mat_hypertable_id) - WHERE - bf.bucket_func::text LIKE '%time_bucket_ng%' - LOOP - CALL _timescaledb_functions.cagg_migrate_to_time_bucket(cagg_name); - END LOOP; -END -$$; diff --git a/sql/updates/post-update.sql b/sql/updates/post-update.sql index b682305ea39..1b75e5efc4d 100644 --- a/sql/updates/post-update.sql +++ b/sql/updates/post-update.sql @@ -171,3 +171,22 @@ $$; -- Repair relations that have relacl entries for users that do not -- exist in pg_authid CALL _timescaledb_functions.repair_relation_acls(); + +-- Migrate existing CAggs using time_bucket_ng to time_bucket +DO $$ +DECLARE + cagg_name regclass; +BEGIN + FOR cagg_name IN + SELECT + pg_catalog.format('%I.%I', user_view_schema, user_view_name)::regclass + FROM + _timescaledb_catalog.continuous_agg + JOIN _timescaledb_catalog.continuous_aggs_bucket_function USING (mat_hypertable_id) + WHERE + bucket_func::text LIKE '%time_bucket_ng%' + LOOP + CALL _timescaledb_functions.cagg_migrate_to_time_bucket(cagg_name); + END LOOP; +END +$$;