Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in data migration of Option.additional_input, sets all values to empty '' (since 2.1.0) #912

Closed
MyPyDavid opened this issue Feb 9, 2024 · 0 comments
Labels
Milestone

Comments

@MyPyDavid
Copy link
Member

MyPyDavid commented Feb 9, 2024

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=True should set additional_input='text'

Steps to reproduce / Schritte zum Reproduzieren

  1. find options in 2.0.x with [i.id for i in Option.objects.all() if i.additional_input]
  2. upgrade to 2.1.x
  3. 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

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))
@jochenklar jochenklar mentioned this issue Feb 10, 2024
@MyPyDavid MyPyDavid added this to the 2.1.3 milestone Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants