migration_helper¶
-
class
Code.migration_helper.
MigrationHelper
[source]¶ Helper class to perform migrations.
Attributes: - migration_status_file :
str
The path to the migration status file.
- migration_status_file_lock :
Lock
The lock for the migration status file.
Methods
_validate_migration_key(key, raise_exception=False) Validate the given migration key. get_migration_status(key) Get the migration status for the given key. set_migration_status(key) Update the migration status file. perform_migration(key) Perform the migration for the given key, if it has not already been performed. migrate_locked_themes() Unlock all locked themes. -
LOCKED_COLLECTION_FIELDS
= 'locked_collection_fields'¶
-
LOCKED_THEMES
= 'locked_themes'¶
-
_validate_migration_key
(self, key, raise_exception=False)[source]¶ Validate the given migration key.
Ensure the given key has a corresponding class attribute and function.
Parameters: Returns: py
bool
Whether the key is valid.
Raises: AttributeError
If the key is invalid and raise_exception is True.
-
get_migration_status
(self, key)[source]¶ Get the migration status for the given key.
Parameters: - key :
str
The key to get the migration status for.
Returns: Optional
[py
bool
]The migration status for the given key, or None if the key is not found.
Examples
>>> MigrationHelper().get_migration_status(key=self.LOCKED_THEMES) True
- key :
-
static
migrate_locked_collection_fields
()[source]¶ Unlock fields locked in collections.
Prior to v0.3.0, fields for collections modified by Themerr-plex were locked which leads to an issue in v0.3.0 and newer, since Themerr-plex will not update locked fields.
-
static
migrate_locked_themes
()[source]¶ Unlock all locked themes.
Prior to v0.3.0, themes uploaded by Themerr-plex were locked which leads to an issue in v0.3.0 and newer, since Themerr-plex will not update locked themes. Additionally, there was no way to know if a theme was added by Themerr-plex or not until v0.3.0, so this migration will unlock all themes.
- migration_status_file :