@@ -171,6 +171,7 @@ ALTER EXTENSION timescaledb DROP SEQUENCE _timescaledb_catalog.chunk_constraint_
171171DROP TABLE _timescaledb_catalog .chunk_constraint ;
172172DROP SEQUENCE _timescaledb_catalog .chunk_constraint_name ;
173173
174+ <<<<<<< HEAD
174175-- remove adaptive chunking
175176DROP FUNCTION IF EXISTS @extschema@.set_adaptive_chunking(regclass, text , regproc);
176177DROP FUNCTION IF EXISTS @extschema@.create_hypertable(relation REGCLASS, time_column_name NAME, partitioning_column NAME, number_partitions INTEGER , associated_schema_name NAME, associated_table_prefix NAME, chunk_time_interval ANYELEMENT, create_default_indexes BOOLEAN , if_not_exists BOOLEAN , partitioning_func REGPROC, migrate_data BOOLEAN , chunk_target_size TEXT , chunk_sizing_func REGPROC, time_partitioning_func REGPROC);
@@ -181,3 +182,99 @@ DROP FUNCTION IF EXISTS _timescaledb_functions.calculate_chunk_interval(integer,
181182-- chunk_target_size is no longer used, so its check constraint is dropped.
182183ALTER TABLE _timescaledb_catalog .hypertable
183184 DROP CONSTRAINT IF EXISTS hypertable_chunk_target_size_check;
185+ =======
186+ -- Rebuild the catalog table `_timescaledb_catalog.continuous_agg` to add the
187+ -- `schema_change_timestamp` column.
188+
189+ -- Drop views and foreign keys that depend on the catalog table.
190+ DROP VIEW IF EXISTS timescaledb_experimental .policies ;
191+ DROP VIEW IF EXISTS timescaledb_information .hypertables ;
192+ DROP VIEW IF EXISTS timescaledb_information .continuous_aggregates ;
193+ DROP VIEW IF EXISTS timescaledb_information .jobs ;
194+
195+ ALTER TABLE _timescaledb_catalog .continuous_aggs_watermark
196+ DROP CONSTRAINT continuous_aggs_watermark_mat_hypertable_id_fkey;
197+ ALTER TABLE _timescaledb_catalog .continuous_aggs_materialization_invalidation_log
198+ DROP CONSTRAINT continuous_aggs_materialization_invalid_materialization_id_fkey;
199+ ALTER TABLE _timescaledb_catalog .continuous_aggs_materialization_ranges
200+ DROP CONSTRAINT continuous_aggs_materialization_ranges_materialization_id_fkey;
201+ ALTER TABLE _timescaledb_catalog .continuous_aggs_jobs_refresh_ranges
202+ DROP CONSTRAINT continuous_aggs_jobs_refresh_ranges_materialization_id_fkey;
203+
204+ ALTER EXTENSION timescaledb
205+ DROP TABLE _timescaledb_catalog .continuous_agg ;
206+
207+ CREATE TABLE _timescaledb_catalog ._tmp_continuous_agg AS
208+ SELECT
209+ mat_hypertable_id,
210+ raw_hypertable_id,
211+ parent_mat_hypertable_id,
212+ user_view_schema,
213+ user_view_name,
214+ partial_view_schema,
215+ partial_view_name,
216+ direct_view_schema,
217+ direct_view_name,
218+ materialized_only
219+ FROM
220+ _timescaledb_catalog .continuous_agg
221+ ORDER BY
222+ mat_hypertable_id;
223+
224+ DROP TABLE _timescaledb_catalog .continuous_agg ;
225+
226+ CREATE TABLE _timescaledb_catalog .continuous_agg (
227+ mat_hypertable_id integer NOT NULL ,
228+ raw_hypertable_id integer NOT NULL ,
229+ parent_mat_hypertable_id integer ,
230+ user_view_schema name NOT NULL ,
231+ user_view_name name NOT NULL ,
232+ partial_view_schema name NOT NULL ,
233+ partial_view_name name NOT NULL ,
234+ direct_view_schema name NOT NULL ,
235+ direct_view_name name NOT NULL ,
236+ materialized_only bool NOT NULL DEFAULT FALSE,
237+ schema_change_timestamp bigint ,
238+ -- table constraints
239+ CONSTRAINT continuous_agg_pkey PRIMARY KEY (mat_hypertable_id),
240+ CONSTRAINT continuous_agg_partial_view_schema_partial_view_name_key UNIQUE (partial_view_schema, partial_view_name),
241+ CONSTRAINT continuous_agg_user_view_schema_user_view_name_key UNIQUE (user_view_schema, user_view_name),
242+ CONSTRAINT continuous_agg_mat_hypertable_id_fkey FOREIGN KEY (mat_hypertable_id) REFERENCES _timescaledb_catalog .hypertable (id) ON DELETE CASCADE ,
243+ CONSTRAINT continuous_agg_raw_hypertable_id_fkey FOREIGN KEY (raw_hypertable_id) REFERENCES _timescaledb_catalog .hypertable (id) ON DELETE CASCADE ,
244+ CONSTRAINT continuous_agg_parent_mat_hypertable_id_fkey FOREIGN KEY (parent_mat_hypertable_id)
245+ REFERENCES _timescaledb_catalog .continuous_agg (mat_hypertable_id) ON DELETE CASCADE
246+ );
247+
248+ INSERT INTO _timescaledb_catalog .continuous_agg
249+ (mat_hypertable_id, raw_hypertable_id, parent_mat_hypertable_id, user_view_schema,
250+ user_view_name, partial_view_schema, partial_view_name, direct_view_schema,
251+ direct_view_name, materialized_only)
252+ SELECT * FROM _timescaledb_catalog ._tmp_continuous_agg ;
253+ DROP TABLE _timescaledb_catalog ._tmp_continuous_agg ;
254+
255+ CREATE INDEX continuous_agg_raw_hypertable_id_idx ON _timescaledb_catalog .continuous_agg (raw_hypertable_id);
256+
257+ SELECT pg_catalog .pg_extension_config_dump (' _timescaledb_catalog.continuous_agg' , ' ' );
258+
259+ GRANT SELECT ON TABLE _timescaledb_catalog .continuous_agg TO PUBLIC;
260+
261+ ALTER TABLE _timescaledb_catalog .continuous_aggs_watermark
262+ ADD CONSTRAINT continuous_aggs_watermark_mat_hypertable_id_fkey
263+ FOREIGN KEY (mat_hypertable_id)
264+ REFERENCES _timescaledb_catalog .continuous_agg (mat_hypertable_id) ON DELETE CASCADE ;
265+ ALTER TABLE _timescaledb_catalog .continuous_aggs_materialization_invalidation_log
266+ ADD CONSTRAINT continuous_aggs_materialization_invalid_materialization_id_fkey
267+ FOREIGN KEY (materialization_id)
268+ REFERENCES _timescaledb_catalog .continuous_agg (mat_hypertable_id) ON DELETE CASCADE ;
269+ ALTER TABLE _timescaledb_catalog .continuous_aggs_materialization_ranges
270+ ADD CONSTRAINT continuous_aggs_materialization_ranges_materialization_id_fkey
271+ FOREIGN KEY (materialization_id)
272+ REFERENCES _timescaledb_catalog .continuous_agg (mat_hypertable_id) ON DELETE CASCADE ;
273+ ALTER TABLE _timescaledb_catalog .continuous_aggs_jobs_refresh_ranges
274+ ADD CONSTRAINT continuous_aggs_jobs_refresh_ranges_materialization_id_fkey
275+ FOREIGN KEY (materialization_id)
276+ REFERENCES _timescaledb_catalog .continuous_agg (mat_hypertable_id) ON DELETE CASCADE ;
277+
278+ ANALYZE _timescaledb_catalog .continuous_agg ;
279+ -- end rebuild _timescaledb_catalog.continuous_agg --
280+ >>>>>>> 73bdc4b27 (Support ADD COLUMN on continuous aggregates)
0 commit comments