Skip to content
Snippets Groups Projects
Commit 302bffbd authored by stvn's avatar stvn
Browse files

Merge PR #145 bd03/migrate/lti_config

* Commits:
  chore: Bump version to 2.7.1
  fix: Manually backfill lti_config dicts
parents 1552134f d44cd795
No related branches found
No related tags found
No related merge requests found
"""
Backfill empty lti_config records
We need to do this with raw SQL,
otherwise the model fails upon instantiation,
as the empty string is an invalid JSON dictionary.
"""
import uuid
from django.db import connection
from django.db import migrations
sql_forward = """\
UPDATE
lti_consumer_lticonfiguration
SET
lti_config = %s
WHERE
id = %s
;\
"""
sql_select_empty = """\
SELECT
id
FROM
lti_consumer_lticonfiguration
WHERE
lti_config = ""
;\
"""
def _get_ids_with_empty_lti_config():
"""
Retrieve the list of primary keys for each entry with a blank lti_config
"""
with connection.cursor() as cursor:
cursor.execute(sql_select_empty)
for row in cursor.fetchall():
yield row[0]
def _forward(apps, schema_editor):
"""
Generate an empty JSON dict for rows missing one
"""
for _id in _get_ids_with_empty_lti_config():
lti_config = '{}'
schema_editor.execute(sql_forward, [
lti_config,
_id,
])
class Migration(migrations.Migration):
"""
Backfill empty lti_config records
"""
dependencies = [
('lti_consumer', '0009_backfill-empty-string-config-id'),
]
operations = [
migrations.RunPython(_forward, atomic=False),
]
...@@ -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.7.0', version='2.7.1',
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