directory.migration
Classes
Takes a directory and the structure/configuration it should have in |
|
Contains methods to migrate fields from one type to another. |
|
Tries to detect structural changes between two formcode blocks. |
Module Contents
- class directory.migration.DirectoryMigration(directory: onegov.directory.models.Directory, new_structure: str | None = None, new_configuration: onegov.directory.types.DirectoryConfiguration | None = None, old_structure: str | None = None)[source]
Takes a directory and the structure/configuration it should have in the future.
It then migrates the existing directory entries, if possible.
- property entries: collections.abc.Iterable[onegov.directory.models.directory_entry.DirectoryEntry][source]
- execute() None[source]
To run the migration, run this method. The other methods below should only be used if you know what you are doing.
- migrate_entry(entry: onegov.directory.models.directory_entry.DirectoryEntry) None[source]
This function is called after an update to the directory structure. During execution of self.execute(), the directory is migrated. On start of looping trough the entries, an auto_flush occurs, calling the migration observer for the directory, which will instantiate yet another instance of the migration. After this inside execute(), the session is not flusing anymore, and we have to skip, since the values are already migrated and migration will fail when removing fieldsets.
- multiple_option_changes_in_one_step() bool[source]
Returns True if there are multiple changes e.g. added and removed options.
- class directory.migration.FieldTypeMigrations[source]
Contains methods to migrate fields from one type to another.
- class directory.migration.StructuralChanges(old_structure: str, new_structure: str)[source]
Tries to detect structural changes between two formcode blocks.
Can only be trusted if the
detection_successfulproperty is True. If it is not, the detection failed because the changes were too great.- old_field(changed: str) onegov.form.parser.core.ParsedField[source]
Returns the field in the old structure for a changed field.
changed_fieldsholds ids as they appear in the new structure, so a field that was renamed (and changed) is stored under its new id, which does not exist inself.old. This resolves the rename to look the field up under its original id.