Legacy Migration
These instructions can be used to migrate a project using the legacy common_storage package to alliance_platform_storage.
Install the alliance_platform_storage package as per the installation instructions.
Note
If this is an older project that is not using the published alliance_platform packages at all you will need to
add the following to settings/base.py (at minimum) if no ALLIANCE_PLATFORM setting already exists:
ALLIANCE_PLATFORM = {
"CORE": {"PROJECT_DIR": PROJECT_DIR},
}
Follow these steps:
For the widget to continue working you will need to copy the
common_storage/templates/widgets/async_file_input.htmlfile to<app>/templates/alliance_platform/storage/widgets/async_file_input.html.<app>can be any of the project specific apps (in the base templatexenopus_frog_appfor example, ordjango_site).Delete the
common_storageapp entirely fromdjango-root, and remove it fromINSTALLED_APPS.Remove
common_storage.test_common_storagefromTEST_APPSinsettings/base.py.The directory structure is changed from
common_storage, so imports and settings references should be replaced as follows:common_storage.s3toalliance_platform.storage.async_uploads.storage.s3common_storage.azuretoalliance_platform.storage.async_uploads.storage.azurecommon_storage.basetoalliance_platform.storage.async_uploads.storage.basecommon_storage.viewstoalliance_platform.storage.async_uploads.viewscommon_storage.registrytoalliance_platform.storage.async_uploads.registrycommon_storage.drftoalliance_platform.storage.async_uploads.rest_frameworkcommon_storage.fields.async_file.AsyncFileFormFieldtoalliance_platform.storage.async_uploads.forms.AsyncFileFieldcommon_storage.fields.async_file.AsyncImageFormFieldtoalliance_platform.storage.async_uploads.forms.AsyncImageFieldcommon_storage.fields.async_file.AsyncFileInputtoalliance_platform.storage.async_uploads.forms.AsyncFileInputcommon_storage.fields.async_file.AsyncFileInputDataValidatortoalliance_platform.storage.async_uploads.forms.AsyncFileInputDataValidatorcommon_storage.fields.async_file.AsyncFileInputDataLengthValidatortoalliance_platform.storage.async_uploads.forms.AsyncFileInputDataLengthValidatorcommon_storage.models.AsyncTempFiletoalliance_platform.storage.async_uploads.models.AsyncTempFileAll remaining instances of
common_storage.fields.async_filetoalliance_platform.storage.async_uploads.models
In
urls.pyremove the paths forDownloadRedirectViewandGenerateUploadView, and add the following instead (if not already done as part of installation):# You can change the path to whatever you like, or add the patterns to the top level path("async-file/", include(default_async_field_registry.get_url_patterns())),
When you migrate, if the common_storage_async_temp_file table exists its data will be copied into the corresponding
table in alliance_platform.storage.
Warning
Before doing this upgrade, check that the
AsyncTempFiletable has the following fields, otherwise the migration will break. If any of these fields don’t exist you will need to first upgrade to the latest version of common_storage.
created_at
original_filename
key
field_name
content_type_id
error
moved_to_location
Notable differences
The only potential breaking change in async uploads between the most recent version of common_storage
and the initial published version of alliance_platform_storage is the addition of the field_id argument to
generate_upload_url() and
generate_download_url(). However, this will only matter if you are
calling these functions directly, or have extended an AsyncUploadStorage class and overridden these methods. If so,
you will just need to update the signature to accept the field_id argument.
ManifestStaticFilesExcludeWebpackStorage
The other change is the removal of the ManifestStaticFilesExcludeWebpackStorage class. Instead, you can now use
ExcludingManifestStaticFilesStorage. Its usage would be something
like:
STORAGES = {
"staticfiles": {
"BACKEND": "alliance_platform.storage.staticfiles.storage.ExcludingManifestStaticFilesStorage",
# Adjust this based on the specific setting name or build directory in your project
"OPTIONS": {"exclude_patterns": [f"{settings.FRONTEND_PRODUCTION_DIR}/*"]},
}
}