Commit 7799376
alxndrsn
test/database-indexes: add easy way to log FK indexes
By changing `false` to `true`, a list of database foreign keys and their corresponding reverse indexes will be printed.
Implemented while try to understand why getodk#1589 required _some_ new "acteeId" reverse-indexes, but not others.
Example output:
```sh
database indexes
┌── Foreign Key Reverse Indexes ───────┐
┌─────────┬──────────────────────────────────────┬─────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────┐
│ (index) │ FK table │ foreign key │ database index │
├─────────┼──────────────────────────────────────┼─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────┤
│ 0 │ 'actors' │ 'actors_acteeid_foreign' │ 'idx_fk_actors_acteeid' │
│ 1 │ 'assignments' │ 'assignments_acteeid_foreign' │ 'idx_fk_assignments_acteeid' │
│ 2 │ 'assignments' │ 'assignments_actorid_foreign' │ 'assignments_pkey' │
│ 3 │ 'assignments' │ 'assignments_roleid_foreign' │ 'idx_fk_assignments_roleid' │
│ 4 │ 'audits' │ 'audits_acteeid_foreign' │ 'audits_acteeid_loggedat_index' │
│ 5 │ 'audits' │ 'audits_actorid_foreign' │ 'audits_actorid_loggedat_index' │
│ 6 │ 'client_audits' │ 'client_audits_blobid_foreign' │ 'idx_fk_client_audits_blobid' │
│ 7 │ 'comments' │ 'comments_actorid_foreign' │ 'idx_fk_comments_actorid' │
│ 8 │ 'comments' │ 'comments_submissionid_foreign' │ 'comments_submissionid_index' │
│ 9 │ 'dataset_form_defs' │ 'dataset_form_defs_datasetid_foreign' │ 'dataset_form_defs_datasetid_formdefid_unique' │
│ 10 │ 'dataset_form_defs' │ 'dataset_form_defs_formdefid_foreign' │ 'idx_fk_dataset_form_defs_formdefid' │
│ 11 │ 'datasets' │ 'datasets_projectid_foreign' │ 'idx_fk_datasets_projectid' │
│ 12 │ 'ds_properties' │ 'ds_properties_datasetid_foreign' │ 'idx_fk_ds_properties_datasetid' │
│ 13 │ 'ds_property_fields' │ 'ds_property_fields_dspropertyid_foreign' │ 'ds_property_fields_dspropertyid_formdefid_unique' │
│ 14 │ 'entities' │ 'entities_createdby_foreign' │ 'idx_fk_entities_creatorid' │
│ 15 │ 'entities' │ 'entities_datasetid_foreign' │ 'entities_datasetid_createdat_id_index' │
│ 16 │ 'entity_def_sources' │ 'entity_def_sources_auditid_foreign' │ 'idx_fk_entity_def_sources_auditid' │
│ 17 │ 'entity_def_sources' │ 'entity_def_sources_submissiondefid_foreign' │ 'idx_fk_entity_def_sources_submissiondefid' │
│ 18 │ 'entity_defs' │ 'entity_defs_entityid_foreign' │ 'entity_defs_entityid_current_index' │
│ 19 │ 'entity_defs' │ 'entity_defs_sourceid_foreign' │ 'entity_defs_sourceid_index' │
│ 20 │ 'entity_submission_backlog' │ 'fk_audit_id' │ 'idx_fk_entity_submission_backlog_auditid' │
│ 21 │ 'entity_submission_backlog' │ 'fk_submission_defs' │ 'idx_fk_entity_submission_backlog_submissiondefid' │
│ 22 │ 'entity_submission_backlog' │ 'fk_submissions' │ 'idx_fk_entity_submission_backlog_submissionid' │
│ 23 │ 'field_keys' │ 'field_keys_actorid_foreign' │ 'field_keys_pkey' │
│ 24 │ 'field_keys' │ 'field_keys_createdby_foreign' │ 'idx_fk_field_keys_createdby' │
│ 25 │ 'field_keys' │ 'field_keys_projectid_foreign' │ 'idx_fk_field_keys_projectid' │
│ 26 │ 'form_attachments' │ 'form_attachments_blobid_foreign' │ 'idx_fk_form_attachments_blobid' │
│ 27 │ 'form_attachments' │ 'form_attachments_datasetid_foreign' │ 'idx_fk_form_attachments_datasetid' │
│ 28 │ 'form_attachments' │ 'form_attachments_formdefid_foreign' │ 'form_attachments_pkey' │
│ 29 │ 'form_attachments' │ 'form_attachments_formid_foreign' │ 'form_attachments_formid_index' │
│ 30 │ 'form_defs' │ 'form_defs_formid_foreign' │ 'form_defs_formid_publishedat_index' │
│ 31 │ 'form_defs' │ 'form_defs_keyid_foreign' │ 'idx_fk_form_defs_keyid' │
│ 32 │ 'form_defs' │ 'form_defs_schemaid_foreign' │ 'idx_fk_form_defs_schemaid' │
│ 33 │ 'form_defs' │ 'form_defs_xlsblobid_foreign' │ 'idx_fk_form_defs_xlsblobid' │
│ 34 │ 'form_field_values' │ 'form_field_values_formid_foreign' │ 'form_field_values_formid_index' │
│ 35 │ 'form_field_values' │ 'form_field_values_submissiondefid_foreign' │ 'form_field_values_submissiondefid_index' │
│ 36 │ 'form_fields' │ 'form_fields_formid_foreign' │ 'form_fields_formid_path_type_index' │
│ 37 │ 'form_fields' │ 'form_fields_schemaid_foreign' │ 'form_fields_pkey' │
│ 38 │ 'forms' │ 'forms_acteeid_foreign' │ 'idx_fk_forms_acteeid' │
│ 39 │ 'forms' │ 'forms_currentdefid_foreign' │ 'idx_fk_forms_currentdefid' │
│ 40 │ 'forms' │ 'forms_draftdefid_foreign' │ 'idx_fk_forms_draftdefid' │
│ 41 │ 'forms' │ 'forms_projectid_foreign' │ 'forms_projectid_xmlformid_deletedat_unique' │
│ 42 │ 'projects' │ 'projects_keyid_foreign' │ 'idx_fk_projects_keyid' │
│ 43 │ 'public_links' │ 'public_links_actorid_foreign' │ 'public_links_pkey' │
│ 44 │ 'public_links' │ 'public_links_createdby_foreign' │ 'idx_fk_public_links_createdby' │
│ 45 │ 'public_links' │ 'public_links_formid_foreign' │ 'idx_fk_public_links_formid' │
│ 46 │ 'sessions' │ 'sessions_actorid_foreign' │ 'sessions_actorid_expires_index' │
│ 47 │ 'submission_attachments' │ 'attachments_blobid_foreign' │ 'idx_fk_submission_attachments_blobid' │
│ 48 │ 'submission_attachments' │ 'submission_attachments_submissiondefid_foreign' │ 'submission_attachments_pkey' │
│ 49 │ 'submission_defs' │ 'submission_defs_actorid_foreign' │ 'idx_fk_submission_defs_submitterid' │
│ 50 │ 'submission_defs' │ 'submission_defs_formdefid_foreign' │ 'idx_fk_submission_defs_formdefid' │
│ 51 │ 'submission_defs' │ 'submission_defs_submissionid_foreign' │ 'submission_defs_submissionid_current_index' │
│ 52 │ 'submission_field_extract_geo_cache' │ 'submission_field_extract_geo_cache_submission_def_id_fkey' │ 'submission_field_extract_geo_cache_pkey' │
│ 53 │ 'submissions' │ 'submissions_formid_foreign' │ 'submissions_formid_instanceid_draft_unique' │
│ 54 │ 'submissions' │ 'submissions_submitter_foreign' │ 'idx_fk_submissions_submitterid' │
│ 55 │ 'user_project_preferences' │ 'user_project_preferences_projectId_fkey' │ 'idx_fk_user_project_preferences_projectid' │
│ 56 │ 'user_project_preferences' │ 'user_project_preferences_userId_fkey' │ 'user_project_preferences_primary_key' │
│ 57 │ 'user_site_preferences' │ 'user_site_preferences_userId_fkey' │ 'user_site_preferences_primary_key' │
│ 58 │ 'users' │ 'users_actorid_foreign' │ 'users_pkey' │
└─────────┴──────────────────────────────────────┴─────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────┘
```1 parent 7739129 commit 7799376
1 file changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
47 | 56 | | |
48 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
49 | 70 | | |
50 | 71 | | |
51 | 72 | | |
| |||
67 | 88 | | |
68 | 89 | | |
69 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
70 | 95 | | |
71 | 96 | | |
72 | 97 | | |
| |||
0 commit comments