Skip to content

Commit

Permalink
Release notes header 2.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Apr 30, 2024
1 parent fc46eab commit bb07c2c
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
91 changes: 91 additions & 0 deletions .unreleased/RELEASE_NOTES_HEADER.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
## {{ release_current }} ({{ release_date }})

This release contains performance improvements and bug fixes since
the {{ release_previous }} release. We recommend that you upgrade at the next
available opportunity.

In addition, it includes these noteworthy features:
* foo
* bar

**For on-premise users and this release only**, you will need to run the following SQL script after running `ALTER EXTENSION`. More details can be found in the pull request [#6786](https://github.com/timescale/timescaledb/pull/6797).

```sql
CREATE OR REPLACE FUNCTION pg_temp.constraint_columns(regclass, int2[]) RETURNS text[] AS
$$
SELECT array_agg(attname) FROM unnest($2) un(attnum) LEFT JOIN pg_attribute att ON att.attrelid=$1 AND att.attnum = un.attnum;
$$ LANGUAGE SQL SET search_path TO pg_catalog, pg_temp;

DO $$
DECLARE
ht_id int;
ht regclass;
chunk regclass;
con_oid oid;
con_frelid regclass;
con_name text;
con_columns text[];
chunk_id int;

BEGIN

-- iterate over all hypertables that have foreign key constraints
FOR ht_id, ht in
SELECT
ht.id,
format('%I.%I',ht.schema_name,ht.table_name)::regclass
FROM _timescaledb_catalog.hypertable ht
WHERE
EXISTS (
SELECT FROM pg_constraint con
WHERE
con.contype='f' AND
con.conrelid=format('%I.%I',ht.schema_name,ht.table_name)::regclass
)
LOOP
RAISE NOTICE 'Hypertable % has foreign key constraint', ht;

-- iterate over all foreign key constraints on the hypertable
-- and check that they are present on every chunk
FOR con_oid, con_frelid, con_name, con_columns IN
SELECT con.oid, con.confrelid, con.conname, pg_temp.constraint_columns(con.conrelid,con.conkey)
FROM pg_constraint con
WHERE
con.contype='f' AND
con.conrelid=ht
LOOP
RAISE NOTICE 'Checking constraint % %', con_name, con_columns;
-- check that the foreign key constraint is present on the chunk

FOR chunk_id, chunk IN
SELECT
ch.id,
format('%I.%I',ch.schema_name,ch.table_name)::regclass
FROM _timescaledb_catalog.chunk ch
WHERE
ch.hypertable_id=ht_id
LOOP
RAISE NOTICE 'Checking chunk %', chunk;
IF NOT EXISTS (
SELECT FROM pg_constraint con
WHERE
con.contype='f' AND
con.conrelid=chunk AND
con.confrelid=con_frelid AND
pg_temp.constraint_columns(con.conrelid,con.conkey) = con_columns
) THEN
RAISE WARNING 'Restoring constraint % on chunk %', con_name, chunk;
PERFORM _timescaledb_functions.constraint_clone(con_oid, chunk);
INSERT INTO _timescaledb_catalog.chunk_constraint(chunk_id, dimension_slice_id, constraint_name, hypertable_constraint_name) VALUES (chunk_id, NULL, con_name, con_name);
END IF;

END LOOP;
END LOOP;

END LOOP;

END
$$;

DROP FUNCTION pg_temp.constraint_columns(regclass, int2[]);
```
File renamed without changes.
8 changes: 4 additions & 4 deletions scripts/merge_changelogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# This script build a CHANGELOG.md entry for a new release
#

RELEASE_NOTES_TEMPLATE='.unreleased/RELEASE_NOTES.md.j2'
RELEASE_NOTES_HEADER_TEMPLATE='.unreleased/RELEASE_NOTES_HEADER.md.j2'

echo_changelog() {
echo "${1}"
# skip the template and release notes files
grep -i "${2}" .unreleased/* | \
grep -v '.unreleased/template.*' | \
grep -v "${RELEASE_NOTES_TEMPLATE}" | \
grep -v "${RELEASE_NOTES_HEADER_TEMPLATE}" | \
cut -d: -f3- | sort | uniq | sed -e 's/^[[:space:]]*//' -e 's/^/* /'
echo
}
Expand All @@ -28,12 +28,12 @@ RELEASE_DATE=$(date +"%Y-%m-%d")
# To install jinja template client:
# $ pip install jinja-cli
#
if [ -f "${RELEASE_NOTES_TEMPLATE}" ];
if [ -f "${RELEASE_NOTES_HEADER_TEMPLATE}" ];
then
jinja \
-D release_current "${RELEASE_CURRENT}" \
-D release_previous "${RELEASE_PREVIOUS}" \
-D release_date "${RELEASE_DATE}" ${RELEASE_NOTES_TEMPLATE}
-D release_date "${RELEASE_DATE}" ${RELEASE_NOTES_HEADER_TEMPLATE}
echo
fi

Expand Down

0 comments on commit bb07c2c

Please sign in to comment.