-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2552 from onaio/update-old-enketo-ids
Add migration to update old enketo urls
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
onadata/apps/main/migrations/0014_update_enketo_old_ids.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
] |