Skip to content

commands.updateworkflowmigrations ​

Overview ​

Management command for updating existing workflow migrations with current function implementations.

Classes ​

add_workflow_identities ​

Copy a change, adding the app and model to every workflow it names by code alone.

Signature ​

add_workflow_identities(value, identities, recorded_at, names_a_workflow)

Parameters ​

NameTypeRequiredDefaultDescription
valueyes
identitiesyes
recorded_atyes
names_a_workflownoFalse

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:219

add_workflow_identities_to_changed_data ​

Return the changes with every workflow reference naming the app and model as well as the code.

Signature ​

add_workflow_identities_to_changed_data(changed_data, identities)

Parameters ​

NameTypeRequiredDefaultDescription
changed_datayes
identitiesyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:247

collect_workflow_identities ​

Return the identities each workflow code has had, in the order they were recorded.

A code can be released by one model and taken over by another, so a code maps to a list rather than to one identity, and which entry a reference means depends on when that reference was recorded.

Each entry also records whether the workflow it names took the code at that change: one added with the code, or one whose code was changed to it. Every other change to a workflow records an entry too, under the code it already held, and can name a different app or model when the workflow's own changed. Telling the two apart is what shows whether one workflow or several have held a code.

Signature ​

collect_workflow_identities(changed_data_lists)

Parameters ​

NameTypeRequiredDefaultDescription
changed_data_listsyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:146

describe_unreadable_changes ​

Return why the command cannot read a migration's changes, or None when it can.

A migration's changed_data can import and still not hold what the command reads from each change, when it has been edited by hand. Checking every change before any is used lets the file be reported and skipped, instead of a missing key ending the whole run with no file named.

Signature ​

describe_unreadable_changes(changed_data)

Parameters ​

NameTypeRequiredDefaultDescription
changed_datayes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:83

get_installed_package_paths ​

Return the directories packages are installed into, normalized for comparison.

A migration under one of them belongs to a package, so the project cannot commit a rewrite of it, and reinstalling the package puts the original back. An editable install leaves its files in their source tree, so it is not under any of these.

Besides the environment's own package directories, these include the base interpreter's, which a virtual environment created with --system-site-packages also imports from, and the user site directory that pip install --user installs into.

On Windows, site.getsitepackages lists each prefix itself alongside its Lib\site-packages. A prefix holds far more than packages, so counting it would treat a project kept inside a Python install, such as a portable or embedded one, as installed. The prefixes are left out.

Signature ​

get_installed_package_paths()

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:45

has_naive_history_dates ​

Return whether any change records a date with no time zone.

Signature ​

has_naive_history_dates(changed_data)

Parameters ​

NameTypeRequiredDefaultDescription
changed_datayes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:123

is_installed_package_path ​

Return whether a path is inside a directory packages are installed into.

Signature ​

is_installed_package_path(path)

Parameters ​

NameTypeRequiredDefaultDescription
pathyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:77

recorded_at_utc ​

Return a recorded date that can be compared with the dates other migrations recorded.

Every date a generated migration records carries a time zone, so a naive one reached the file by hand. UTC is what the generated ones hold, so reading a naive date as UTC keeps it comparable and puts it where its author meant it to sit. The date in the file is left as it was written.

Signature ​

recorded_at_utc(recorded)

Parameters ​

NameTypeRequiredDefaultDescription
recordedyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:110

workflow_identity_at ​

Return what a workflow code meant when a change naming it was recorded, or None when that cannot be told.

Signature ​

workflow_identity_at(identities, code, recorded_at)

Parameters ​

NameTypeRequiredDefaultDescription
identitiesyes
codeyes
recorded_atyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:193

workflow_identity_of ​

Return the app and model a workflow change names, exactly as the change recorded them.

A field the change altered is returned as the (old, new) pair it is recorded as, because the workflow's own id is read with get_id_values_from_dict, which picks the side the direction of travel calls for.

A change that recorded neither column names a workflow whose columns are blank: replaying the change creates the row through a migration-state model, which has none of the save() that fills those columns in, so blank is what the row ends up holding. makeworkflowmigrations writes the workflow's own id the same way, so a reference has to agree with it to match.

Signature ​

workflow_identity_of(changes)

Parameters ​

NameTypeRequiredDefaultDescription
changesyes

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py:131

Source ​

server/vueda/workflow/management/commands/updateworkflowmigrations.py