첫 번째 컨테이너에서는 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
제가 볼 때, not-null 제약 조건을 생성하는 업그레이드 작업 AddAssignedToTypeToAssignments는 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');
이후 컨테이너를 재빌드할 수 있었습니다.