Skip to content

Commit

Permalink
Make migrations compatible with Postgres 14 (#338)
Browse files Browse the repository at this point in the history
Closes: #338
  • Loading branch information
holtgrewe committed Feb 8, 2022
1 parent ee0d5e0 commit a36d01d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions variants/migrations/0041_array_cat_agg.py
Expand Up @@ -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):
Expand All @@ -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
),
)
]

0 comments on commit a36d01d

Please sign in to comment.