最初のコンテナで SKIP_POST_DEPLOYMENT_MIGRATIONS が有効な状態で、安定版 (v2.7.8) への更新を行いました。
その後、別のコンテナで skip オプションを無効にして再度実行したところ、CorrectlyMoveAssignmentsFromCustomFieldsToATable というマイグレーションタスクが失敗しました。
PG::NotNullViolation: ERROR: null value in column "assigned_to_type"
of relation "assignments" violates not-null constraint
私の理解では、AddAssignedToTypeToAssignments というアップグレードタスク(not-null 制約の作成)は、CorrectlyMoveAssignmentsFromCustomFieldsToATable が完了するまで実行されるべきではありません。
回避策として、以下を実行しました。
INSERT INTO assignments
(assigned_to_id, assigned_by_user_id, topic_id, created_at, updated_at,assigned_to_type)
SELECT
assigned_to.value::integer,
assigned_by.value::integer,
assigned_by.topic_id,
assigned_by.created_at,
assigned_by.updated_at,
'User'
FROM topic_custom_fields assigned_by
INNER JOIN topic_custom_fields assigned_to
ON assigned_to.topic_id = assigned_by.topic_id
WHERE assigned_by.name = 'assigned_by_id'
AND assigned_to.name = 'assigned_to_id'
ORDER BY assigned_by.created_at DESC
ON CONFLICT DO NOTHING;
INSERT INTO schema_migration_details
(version,
name,
hostname,
git_version,
rails_version,
duration,
direction,
created_at)
values(
'20210714173022',
'CorrectlyMoveAssignmentsFromCustomFieldsToATable',
'ce4fb45daf62',
'98b0621d538fa4e8a53e1e74127c24c384be9b58',
'6.1.3.2',
0,
'up',
'2021-09-28 15:20:00.123456'
);
INSERT INTO schema_migrations values('20210714173022');
その後、コンテナを再構築することができました。