Skip to content

Commit

Permalink
projects: fix point migration by splitting it into separate migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Feb 19, 2025
1 parent cffc3e2 commit b955a67
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 32 deletions.
33 changes: 1 addition & 32 deletions adhocracy4/projects/migrations/0049_project_geos_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import json
import logging
import django.contrib.gis.db.models.fields

from django.contrib.gis.geos import GEOSGeometry
from django.contrib.gis.geos import Point
from django.db import migrations, models
from django.db import migrations

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -40,13 +38,6 @@ def migrate_project_point_field(apps, schema_editor):
project.save()


def migrate_project_geos_point_field(apps, schema_editor):
project = apps.get_model("a4projects", "Project")
for project in project.objects.all():
project.point = project.geos_point
project.save()


class Migration(migrations.Migration):

dependencies = [
Expand All @@ -57,26 +48,4 @@ class Migration(migrations.Migration):
migrations.RunPython(
migrate_project_point_field, reverse_code=migrations.RunPython.noop
),
migrations.RemoveField(
model_name="project",
name="point",
),
migrations.AddField(
model_name="project",
name="point",
field=django.contrib.gis.db.models.fields.PointField(
blank=True,
help_text="Locate your project. Click inside the marked area or type in an address to set the marker. A set marker can be dragged when pressed.",
null=True,
srid=4326,
verbose_name="Can your project be located on the map?",
),
),
migrations.RunPython(
migrate_project_geos_point_field, reverse_code=migrations.RunPython.noop
),
migrations.RemoveField(
model_name="project",
name="geos_point",
),
]
30 changes: 30 additions & 0 deletions adhocracy4/projects/migrations/0050_replace_point_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.17 on 2025-02-19 15:46

import django.contrib.gis.db.models.fields

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("a4projects", "0049_project_geos_point"),
]

operations = [
migrations.RemoveField(
model_name="project",
name="point",
),
migrations.AddField(
model_name="project",
name="point",
field=django.contrib.gis.db.models.fields.PointField(
blank=True,
help_text="Locate your project. Click inside the marked area or type in an address to set the marker. A set marker can be dragged when pressed.",
null=True,
srid=4326,
verbose_name="Can your project be located on the map?",
),
),
]
23 changes: 23 additions & 0 deletions adhocracy4/projects/migrations/0051_migrate_point_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.17 on 2025-02-19 15:49

from django.db import migrations


def migrate_project_geos_point_field(apps, schema_editor):
project = apps.get_model("a4projects", "Project")
for project in project.objects.all():
project.point = project.geos_point
project.save()


class Migration(migrations.Migration):

dependencies = [
("a4projects", "0050_replace_point_field"),
]

operations = [
migrations.RunPython(
migrate_project_geos_point_field, reverse_code=migrations.RunPython.noop
),
]
17 changes: 17 additions & 0 deletions adhocracy4/projects/migrations/0052_remove_geos_point_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.17 on 2025-02-19 15:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("a4projects", "0051_migrate_point_field"),
]

operations = [
migrations.RemoveField(
model_name="project",
name="geos_point",
),
]

0 comments on commit b955a67

Please sign in to comment.