Skip to content

Commit

Permalink
Merge pull request #5812 from nyaruka/no_postgis
Browse files Browse the repository at this point in the history
Allow running migrations without PostGIS
  • Loading branch information
rowanseymour authored Jan 16, 2025
2 parents b77c003 + 02a1741 commit 7ef4cac
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ports:
- 6379:6379
postgres:
image: postgis/postgis:15-3.3-alpine
image: postgres:15-alpine
env:
POSTGRES_DB: temba
POSTGRES_USER: temba
Expand Down Expand Up @@ -63,6 +63,8 @@ jobs:
port: 6000

- name: Initialize environment
env:
POSTGIS: 'OFF'
run: |
poetry install --no-root
yarn install
Expand All @@ -85,6 +87,8 @@ jobs:
poetry run python manage.py compress --extension=".html" --settings=temba.settings_compress
- name: Run tests
env:
POSTGIS: 'OFF'
run: |
poetry run coverage run manage.py test --keepdb --noinput --verbosity=2
poetry run coverage report -i
Expand Down
6 changes: 5 additions & 1 deletion temba/locations/migrations/0031_squashed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class Migration(migrations.Migration):
("path", models.CharField(max_length=768)),
(
"simplified_geometry",
django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326),
(
django.contrib.gis.db.models.fields.MultiPolygonField(null=True, srid=4326)
if settings.POSTGIS
else models.TextField()
),
),
("lft", models.PositiveIntegerField(editable=False)),
("rght", models.PositiveIntegerField(editable=False)),
Expand Down
5 changes: 5 additions & 0 deletions temba/locations/migrations/0034_populate_json_geometry.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Generated by Django 5.1.4 on 2025-01-10 14:30

import geojson

from django.conf import settings
from django.db import migrations


def populate_boundary_geometry(apps, schema_editor): # pragma: no cover
if not settings.POSTGIS:
return

AdminBoundary = apps.get_model("locations", "AdminBoundary")

boundaries = AdminBoundary.objects.all().order_by("level", "osm_id")
Expand Down
5 changes: 4 additions & 1 deletion temba/settings_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

DATA_UPLOAD_MAX_NUMBER_FIELDS = 2500 # needed for exports of big workspaces

# Temp workaround to allow running migrations without PostGIS
POSTGIS = os.getenv("POSTGIS") != "OFF"

# -----------------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------------
Expand Down Expand Up @@ -628,7 +631,7 @@
# Database
# -----------------------------------------------------------------------------------
_default_database_config = {
"ENGINE": "django.contrib.gis.db.backends.postgis",
"ENGINE": "django.contrib.gis.db.backends.postgis" if POSTGIS else "django.db.backends.postgresql",
"NAME": "temba",
"USER": "temba",
"PASSWORD": "temba",
Expand Down

0 comments on commit 7ef4cac

Please sign in to comment.