Skip to content
Snippets Groups Projects
Unverified Commit 59b7c431 authored by Kshitij Sobti's avatar Kshitij Sobti
Browse files

Fix migration `config_id` conflict.

A previous PR (#130) added a new unique field with a default value to the
LtiConfiguration model. Such cases need special handling in migraiton, however
the previous PR did not include that. This commit fixes the migration to include
the special handling for new unique fields.
parent 1557549e
No related branches found
No related tags found
No related merge requests found
...@@ -298,6 +298,11 @@ Please do not report security issues in public. Send security concerns via email ...@@ -298,6 +298,11 @@ Please do not report security issues in public. Send security concerns via email
Changelog Changelog
========= =========
2.5.2 - 2021-01-20
------------------
* Fix issue with migration that causes migration failure due to duplicate `config_id` values.
2.5.1 - 2021-01-19 2.5.1 - 2021-01-19
------------------ ------------------
......
...@@ -6,6 +6,13 @@ import jsonfield.fields ...@@ -6,6 +6,13 @@ import jsonfield.fields
import uuid import uuid
def create_config_ids(apps, schema_editor):
LtiConfiguration = apps.get_model('lti_consumer', 'LtiConfiguration')
for config in LtiConfiguration.objects.all():
config.config_id = uuid.uuid4()
config.save()
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
...@@ -14,6 +21,12 @@ class Migration(migrations.Migration): ...@@ -14,6 +21,12 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='lticonfiguration',
name='config_id',
field=models.UUIDField(default=uuid.uuid4, null=True),
),
migrations.RunPython(create_config_ids),
migrations.AlterField(
model_name='lticonfiguration', model_name='lticonfiguration',
name='config_id', name='config_id',
field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True), field=models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
......
...@@ -49,7 +49,7 @@ with open('README.rst') as _f: ...@@ -49,7 +49,7 @@ with open('README.rst') as _f:
setup( setup(
name='lti-consumer-xblock', name='lti-consumer-xblock',
version='2.5.1', version='2.5.2',
description='This XBlock implements the consumer side of the LTI specification.', description='This XBlock implements the consumer side of the LTI specification.',
long_description=long_description, long_description=long_description,
long_description_content_type='text/x-rst', long_description_content_type='text/x-rst',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment