diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 427536391..7fc5342b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,8 @@ jobs: postgres-version: '11' - python-version: '3.8' postgres-version: '13' -# Postgres 14 is currently not supported. -# -# See https://github.com/bihealth/varfish-server/issues/338 -# -# - python-version: '3.8' -# postgres-version: '14' + - python-version: '3.8' + postgres-version: '14' services: redis: image: redis:latest diff --git a/HISTORY.rst b/HISTORY.rst index 4b93ab569..3b5cef3a6 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -93,6 +93,7 @@ Full Change List - Fix issue with variant annotation export (#328) - Adding REST API versioning to (#333) - Adding more postgres versions to CI (#337) +- Make migrations compatible with Postgres 14 (#338) ------- v0.23.9 diff --git a/variants/migrations/0041_array_cat_agg.py b/variants/migrations/0041_array_cat_agg.py index 13765d898..59f68b9d4 100644 --- a/variants/migrations/0041_array_cat_agg.py +++ b/variants/migrations/0041_array_cat_agg.py @@ -3,7 +3,11 @@ Update all existing case""" from __future__ import unicode_literals -from django.db import migrations +from django.db import connection, migrations + + +POSTGRES_VERSION = connection.cursor().connection.server_version +ARRAY_TYPE = "anyarray" if POSTGRES_VERSION < 140000 else "anycompatiblearray" class Migration(migrations.Migration): @@ -13,13 +17,17 @@ class Migration(migrations.Migration): operations = [ migrations.RunSQL( """ - CREATE AGGREGATE array_cat_agg(anyarray) ( + CREATE AGGREGATE array_cat_agg({array_type}) ( SFUNC=array_cat, - STYPE=anyarray + STYPE={array_type} ); - """, + """.format( + array_type=ARRAY_TYPE + ), """ - DROP AGGREGATE array_cat_agg(anyarray); - """, + DROP AGGREGATE array_cat_agg({array_type}); + """.format( + array_type=ARRAY_TYPE + ), ) ]