데이터베이스 무결성을 확인하는 가장 좋은 방법은 무엇인가요?

한 포럼의 사용자, 주제, 게시물을 다른 포럼으로 병합하고 싶습니다. 개발 환경에 포럼을 복원하는 데는 문제가 없지만, 병합을 시도할 때(현재는 새로 설치된 환경으로) PG::ForeignKeyViolation 오류가 발생합니다. 데이터베이스의 무결성을 확인할 수 있는 Discourse 도구가 있는지 궁금합니다. 없다면 다른 팁이나 아이디어가 있을까요?

(데이터베이스 관련 문제와 관련된 몇 가지 주제도 있어서, 현재 그런 도구가 없다면 DC 팀이 이 기능을 도입할 가치가 있다고 생각할지 궁금합니다.)

5년 이상 전에 시작된 Discourse 포럼의 스키마와 새로 설치한 스키마를 수동으로 diff 해보았는데, 차이를 아래에서 확인할 수 있습니다:

https://www.diffchecker.com/lZrp2jxJ

대부분 bigint에서 integer로, character varying(255)에서 character varying으로 변경된 것과 몇 가지 not null 제약이 누락된 것뿐이지만, 일부 인덱스도 누락되어 있습니다.

그것을 가리키는 라인들은 다음과 같습니다:

1646행 - 누락:

  Index "public.index_badges_on_badge_type_id"
 Column |          Type          | Key? | Definition 		    Column     |  Type   | Key? |  Definition   
--------+------------------------+------+------------		---------------+---------+------+---------------
 name   | character varying(255) | yes  | name		 badge_type_id | integer | yes  | badge_type_id
btree, for table "public.badges"

3301행 - 누락:

	Index "public.index_user_badges_on_user_id"
 Column  |  Type   | Key? | Definition 
---------+---------+------+------------
 user_id | integer | yes  | user_id
btree, for table "public.user_badges"

4639행 - 누락:

	      Index "public.schema_migrations_pkey"
 Column  |       Type        | Key? | Definition 
---------+-------------------+------+------------
 version | character varying | yes  | version
primary key, btree, for table "public.schema_migrations"

5487행 - 일부 누락:

                                       Table "public.topic_search_data"
   Column    |          Type          | Collation | Nullable | Default 		   Column    |       Type        | Collation | Nullable |                       Default                       
-------------+------------------------+-----------+----------+---------		-------------+-------------------+-----------+----------+-----------------------------------------------------
 topic_id    | integer                |           | not null | 		 topic_id    | integer           |           | not null | nextval('topic_search_data_topic_id_seq'::regclass)
 raw_data    | text                   |           |          | 		 raw_data    | text              |           |          | 
 locale      | character varying(255) |           | not null | 		 locale      | character varying |           | not null | 
 search_data | tsvector               |           |          | 		 search_data | tsvector          |           |          | 
 version     | integer                |           |          | 0		 version     | integer           |           |          | 0

5506행 - 누락:

           Sequence "public.topic_search_data_topic_id_seq"
  Type   | Start | Minimum |  Maximum   | Increment | Cycles? | Cache 
---------+-------+---------+------------+-----------+---------+-------
 integer |     1 |       1 | 2147483647 |         1 | no      |     1
Owned by: public.topic_search_data.topic_id

6044행 - 누락:

    "index_user_badges_on_user_id" btree (user_id)

여기서 무언가 걱정해야 할 점이 있을까요? 인덱스를 수동으로 추가해야 할까요? 다른 생각이나 눈에 띄는 부분이 있는지 알려주시면 좋겠습니다(여기서는 새벽 5시 가까이 되어서 눈을 뜨기가 힘드네요 :see_no_evil:)