ID 603823 - Migration from "master files" can create Source Files that belong to a different Show than the associated Asset, resulting in Source File entries that fail to Archive

Follow

Problem summary:
Migration from "master files" can create Source Files that belong to a different Show than the associated Asset, resulting in Source File entries that fail to Archive
 
Customer reported version:
Flix 7.1.1
 
Customer reported platform:
CentOS 7
 
Steps to reproduce:
1) Open Flix using the attached database file
2) Attempt to Archive one of the affected Shows: 2, 4, 8
3) Observe the could not process required relation assets for *entity.Entity warnings in the logs.
 
Expected behavior:
When migrating to Source Files, the Assets associated with the new Source Files should utilize the same Show ID. 
 
Actual behavior:
During the migration to Source Files, it's possible for Source Files to belong to a Show that is not the same as their Asset, which will prevent the Source Files from Archiving as expected. 
 
Workaround:
1) Run the following query to list affected Source Files:

SELECT entity.*, bucket.show_id as asset_show_id FROM entity    JOIN asset_entity_type ON asset_entity_type.entity_id = entity.id    JOIN asset ON asset.asset_id = asset_entity_type.asset_id    JOIN bucket ON bucket.id = asset.bucket_idWHERE entity.show_id <> bucket.show_id;
2) Run the following query to update all Source File entries to belong to the same Show as the asset. This will fix incorrect entries in all Shows, but it is a relatively low-risk query:
UPDATE entity    JOIN asset_entity_type ON asset_entity_type.entity_id = entity.id    JOIN asset ON asset.asset_id = asset_entity_type.asset_id    JOIN bucket ON bucket.id = asset.bucket_idSET entity.show_id = bucket.show_idWHERE entity.show_id <> bucket.show_id;
 
Reproduced by Development team

    We're sorry to hear that

    Please tell us why