-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Labels
Milestone
Description
Description / Beschreibung
we have one Issue with the update from 2.0.x to 2.1.2 in the text fields of the options.
The previous additional_input=True fields are missing and all converted into -----
Expected behaviour / Erwartetes Verhalten
- previous
additional_input=Trueshould setadditional_input='text'
Steps to reproduce / Schritte zum Reproduzieren
- find options in 2.0.x with
[i.id for i in Option.objects.all() if i.additional_input] - upgrade to 2.1.x
- list
[i.id for i in Option.objects.all() if i.additional_input]is now empty
Context / Kontext
Please state your operating system, the RDMO version, and (if applicable) the browser the error occured in.
References / Verweise
- d511cb8#r138461089
- https://stackoverflow.com/questions/70953704/how-to-cleanly-migrate-booleanfield-to-charfield
Possible fix from backup
From previous backup DB:
list_options_additional_true = [i.id for i in Option.objects.all() if i.additional_input]
# to write to .txt
from pathlib import Path
_lst="\n".join(map(str, list_options_additional_true))
Path.cwd.joinpath('option_additional_true_ids.txt').write_text(_lst,encoding='UTF-8')Keep this list open or copy the values into a .txt
In newly upgraded DB:
# copy the list into
# list_options_additional_true = ...
# or read from .txt
_lst = Path.cwd().joinpath('option_additional_true_ids.txt').read_text(encoding='UTF-8')
list_options_additional_true = list(map(int, _lst.split()))
objs = Option.objects.filter(id__in = list_options_additional_true)
[setattr(i, 'additional_input', 'text') for i in objs]
Option.objects.bulk_update(objs,['additional_input'])
#done
# to see the unique values in DB
set(Option.objects.all().values_list('additional_input',flat=True))