Skip to content

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

@MyPyDavid

Description

@MyPyDavid

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions