Skip to content

Commit

Permalink
Add migration to update old enketo urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ciremusyoka committed Feb 8, 2024
1 parent 67c1615 commit 74c4aed
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 74c4aed

Please sign in to comment.