Skip to content

ESoCC: Migration command to ensure channel versioned content databases exist #5592

@AlexVelezLl

Description

@AlexVelezLl

This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

For the usual workflow of the Easy Sharing of Community Channels project, we rely on having the channel versioned database available in the storage so that it can be used by the admins to import that specific channel version for review before approving a given submission, and this versioned database is the one that gets finally mapped into the public models once a submission is approved.

The problem is that the creation of the versioned databases is something relatively new, and old channels that have not been published recently do not have them set up; they only have their main content databases (i.e., {channel_id}.sqlite3). However, its main content databases are the same as their most recent versioned database, so we can copy this file to set up the most recent version database.

Until now, we were doing this by invoking a background task on a CommunityLibrarySubmission creation to make sure the versioned content database existed in the storage so that it is available in a future stage. However, now we will use a migration command to ensure that all channels in Studio have a versioned content database for their most recent version.

Technical details

For this, we will:

  • Create a new command on contentcuration/contentcuration/management/commands/ensure_versioned_databases_exist.py.
  • Query all main_tree.published=True Channels.
  • Iterate through each channel, and call the ensure_versioned_database_exists method for each
    • Use .iterator() method to iterate through the channels to prevent fetching all channels at once.
  • Since this will fix the issue from the root, we can now remove the ensure_versioned_database_exists_task and all its references.

Acceptance criteria

  • A new ensure_versioned_databases_exist command is created.
  • After running the command, all published channels should have a versioned content database after running this command.

Metadata

Metadata

Assignees

Labels

P0 - criticalPriority: Release blocker or regression

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions