You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ESoCC: Create migration command to create ChannelVersion models for old channels #5593
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
The ChannelVersion model is a new model in Studio that will allow us to track the channel version history using Django models (until now, we were doing this by looking at the channel.published_data field), and to have relations of other models to specific channel versions.
As we will try to make the ChannelVersion more of a standard for querying channel version information in the future, we will need to migrate all the data that we already have stored in the channel.published_data field to ChannelVersion instances, and set the propper channel.version_info relation, so that we make sure that all published channels have a channel.version_info object set.
Technical details
For this:
Create a new command on contentcuration/contentcuration/management/commands/create_channel_versions.py.
Query all version>0 Channels (note that we are not using the main_tree.published field to support deleted channels).
Iterate through the channels using the .iterator() method to prevent loading all channels at once. For each channel:
Create a ChannelVersion instance for each version present in its published_data field. Use the data present in this object to populate the information of the ChannelVersion instance. If, for some reason, published_data is null, then manually create a ChannelVersion only for the current channel version.
Only for the current version of the channel:
Set the created ChannelVersion instance as the channel version_info field.
If any of the following fields are missing: included_licenses, included_categories, included_languages, non_distributable_licenses_included, or special_permissions_included, then:
Load the content database of that channel
Compute all these properties. Try to reuse as much code as possible from the current fill_published_fields method.
When creating the AuditedSpecialPermissionsLicense objects, if the channel is public, then set the distributable field to true.
Acceptance criteria
A new create_channel_versions command is created.
After running the command, all channels with a version > 0 should have their version_info field set.
After running the command, all published_data versions of all channels are now available as ChannelVersion instances.
Activity