Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash / clean up (old) migrations #4973

Merged
merged 10 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading