numbas / numbas-lti-provider

An LTI tool provider to run Numbas exams
https://docs.numbas.org.uk/lti/en/latest/
Other
11 stars 12 forks source link

Faulty migration #263

Closed jhoobergs closed 1 year ago

jhoobergs commented 1 year ago
jhoobergs commented 1 year ago

Following migration seems to fix it for me:

# Generated by Django 3.2.16 on 2022-11-30 08:58

from django.db import migrations
from numbas_lti.models import Resource

class Migration(migrations.Migration):

    dependencies = [
        ('numbas_lti', '0077_merge_0075_auto_20221018_1102_0076_resource_subject'),
    ]

    def fix_require_lockdown_app(apps, schema_editor):
        for resource in Resource.objects.all():
            if resource.require_lockdown_app == "0":
                resource.require_lockdown_app = ""
                resource.save()
            elif resource.require_lockdown_app == "1":
                resource.require_lockdown_app = "numbas"
                resource.save()

    operations = [
        migrations.RunPython(fix_require_lockdown_app),
    ]

(the dependency should be different)

christianp commented 1 year ago

Thanks for spotting this. I hadn't got round to testing the migration with a new instance yet. I've squashed the migrations, so anyone running this on existing databases from now on will get the correct values in that field.