Skip to content

Commit

Permalink
Merge pull request #4973 from open-formulieren/release/4920-3.0-squas…
Browse files Browse the repository at this point in the history
…h-migrations

Squash / clean up (old) migrations
  • Loading branch information
sergei-maertens authored Dec 30, 2024
2 parents 82e76ec + 7d6be9c commit eeae60c
Show file tree
Hide file tree
Showing 20 changed files with 2,281 additions and 543 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
start: ['2.7.4', '2.7.8']
start: ['2.8.2']

steps:
- uses: actions/checkout@v4
Expand Down
367 changes: 367 additions & 0 deletions src/openforms/analytics_tools/migrations/0001_initial_to_v300.py

Large diffs are not rendered by default.

53 changes: 2 additions & 51 deletions src/openforms/config/migrations/0054_v250_to_v270.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,12 @@
from django.db import migrations, models

import tinymce.models
from flags.conditions import boolean_condition

import openforms.config.models.config
import openforms.emails.validators
import openforms.payments.validators
import openforms.template.validators

FIELDS = (
"enable_demo_plugins",
"display_sdk_information",
)


def move_from_config_to_flagstate(apps, _):
GlobalConfiguration = apps.get_model("config", "GlobalConfiguration")
FlagState = apps.get_model("flags", "FlagState")

# ensure we have an instance, for a fresh install, this will set up the
# defaults explicitly.
config = GlobalConfiguration.objects.first() or GlobalConfiguration()
for field in FIELDS:
current_value = getattr(config, field)
FlagState.objects.get_or_create(
name=field.upper(),
defaults={
"condition": "boolean",
"value": str(current_value),
"required": False,
},
)


def move_from_flagstate_to_config(apps, _):
GlobalConfiguration = apps.get_model("config", "GlobalConfiguration")
FlagState = apps.get_model("flags", "FlagState")

# if there's no config, there's nothing to do
config = GlobalConfiguration.objects.first()
if config is None:
return

for field in FIELDS:
flag_state = FlagState.objects.filter(
name=field.upper(), condition="boolean"
).first()
if flag_state is None:
continue

value = boolean_condition(flag_state.value)
setattr(config, field, value)

config.save()


class Migration(migrations.Migration):

Expand Down Expand Up @@ -162,10 +115,8 @@ class Migration(migrations.Migration):
model_name="globalconfiguration",
name="show_form_link_in_cosign_email",
),
migrations.RunPython(
code=move_from_config_to_flagstate,
reverse_code=move_from_flagstate_to_config,
),
# RunPython operation removed as part of 3.0 release cycle - these migrations are
# guaranteed to have been executed on Open Forms 2.8.x for existing instances.
migrations.RemoveField(
model_name="globalconfiguration",
name="display_sdk_information",
Expand Down
Loading

0 comments on commit eeae60c

Please sign in to comment.