Skip to content

Commit

Permalink
Merge pull request #2552 from onaio/update-old-enketo-ids
Browse files Browse the repository at this point in the history
Add migration to update old enketo urls
  • Loading branch information
KipSigei authored Mar 7, 2024
2 parents e0ef23c + 04f152c commit 02e8e92
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions onadata/apps/main/migrations/0014_update_enketo_old_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.23 on 2024-02-08 10:46

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('main', '0013_passwordhistory'),
]

operations = [
migrations.RunSQL("UPDATE main_metadata SET data_value = REPLACE(data_value, '#', '') \
WHERE data_type = 'enketo_url' AND id IN (SELECT id FROM main_metadata \
WHERE data_type = 'enketo_url' AND UPPER(data_value) LIKE '%#%') ;",
migrations.RunSQL.noop),
migrations.RunSQL("UPDATE main_metadata SET data_value = REPLACE(data_value, '_', 'x') \
WHERE data_type = 'enketo_url' AND id IN (SELECT id FROM main_metadata \
WHERE data_type = 'enketo_url' AND UPPER(data_value) LIKE '%\_%');",
migrations.RunSQL.noop)
]

0 comments on commit 02e8e92

Please sign in to comment.