diff --git a/openslides_backend/migrations/migrations/mig_0103_update_indexes/indexes.py b/openslides_backend/migrations/migrations/mig_0103_update_indexes/indexes.py index 245a4234a5..34caa5334c 100644 --- a/openslides_backend/migrations/migrations/mig_0103_update_indexes/indexes.py +++ b/openslides_backend/migrations/migrations/mig_0103_update_indexes/indexes.py @@ -29,19 +29,37 @@ "contype": "u", "fields": "content_object_id_topic_id", }, + "idx_agenda_item_t_parent_id": {"contype": None, "field": "parent_id"}, + "idx_agenda_item_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "assignment_t": { "unique_assignment_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_assignment_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, + "assignment_candidate_t": { + "idx_assignment_candidate_t_assignment_id": { + "contype": None, + "field": "assignment_id", + }, + "idx_assignment_candidate_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_assignment_candidate_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, }, "chat_group_t": { "unique_chat_group_meeting_id_name": { "contype": "u", "fields": "meeting_id, name", "strict": False, - } + }, + "idx_chat_group_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "nm_chat_group_read_group_ids_group_t": { "pk_nm_chat_group_read_group_ids_group_t": { @@ -71,12 +89,25 @@ "field": "group_id", }, }, + "chat_message_t": { + "idx_chat_message_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_chat_message_t_chat_group_id": {"contype": None, "field": "chat_group_id"}, + "idx_chat_message_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, "committee_t": { "unique_committee_external_id": {"contype": "u", "fields": "external_id"}, "unique_committee_default_meeting_id": { "contype": "u", "fields": "default_meeting_id", }, + "idx_committee_t_parent_id": {"contype": None, "field": "parent_id"}, + "idx_committee_t_organization_id": { + "contype": None, + "field": "organization_id", + }, }, "nm_committee_manager_ids_user_t": { "pk_nm_committee_manager_ids_user_t": { @@ -120,13 +151,33 @@ "field": "forward_to_committee_id", }, }, - "gender_t": {"unique_gender_name": {"contype": "u", "fields": "name"}}, + "gender_t": { + "unique_gender_name": {"contype": "u", "fields": "name"}, + "idx_gender_t_organization_id": {"contype": None, "field": "organization_id"}, + }, "group_t": { "unique_group_meeting_id_external_id": { "contype": "u", "fields": "meeting_id, external_id", "strict": False, - } + }, + "idx_group_t_used_as_motion_poll_default_id": { + "contype": None, + "field": "used_as_motion_poll_default_id", + }, + "idx_group_t_used_as_assignment_poll_default_id": { + "contype": None, + "field": "used_as_assignment_poll_default_id", + }, + "idx_group_t_used_as_topic_poll_default_id": { + "contype": None, + "field": "used_as_topic_poll_default_id", + }, + "idx_group_t_used_as_poll_default_id": { + "contype": None, + "field": "used_as_poll_default_id", + }, + "idx_group_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "nm_group_meeting_user_ids_meeting_user_t": { "pk_nm_group_meeting_user_ids_meeting_user_t": { @@ -203,6 +254,25 @@ "idx_nm_group_poll_ids_poll_t_group_id": {"contype": None, "field": "group_id"}, "idx_nm_group_poll_ids_poll_t_poll_id": {"contype": None, "field": "poll_id"}, }, + "history_entry_t": { + "idx_history_entry_t_model_id_user_id": { + "contype": None, + "field": "model_id_user_id", + }, + "idx_history_entry_t_model_id_motion_id": { + "contype": None, + "field": "model_id_motion_id", + }, + "idx_history_entry_t_model_id_assignment_id": { + "contype": None, + "field": "model_id_assignment_id", + }, + "idx_history_entry_t_position_id": {"contype": None, "field": "position_id"}, + "idx_history_entry_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, + "history_position_t": { + "idx_history_position_t_user_id": {"contype": None, "field": "user_id"} + }, "list_of_speakers_t": { "unique_list_of_speakers_sequential_number_meeting_id": { "contype": "u", @@ -228,6 +298,7 @@ "contype": "u", "fields": "content_object_id_meeting_mediafile_id", }, + "idx_list_of_speakers_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "mediafile_t": { "unique_mediafile_title_parent_id_owner_id": { @@ -236,9 +307,34 @@ "strict": True, }, "unique_mediafile_token": {"contype": "u", "fields": "token"}, + "idx_mediafile_t_published_to_meetings_in_organization_id": { + "contype": None, + "field": "published_to_meetings_in_organization_id", + }, + "idx_mediafile_t_parent_id": {"contype": None, "field": "parent_id"}, + "idx_mediafile_t_owner_id_meeting_id": { + "contype": None, + "field": "owner_id_meeting_id", + }, + "idx_mediafile_t_owner_id_organization_id": { + "contype": None, + "field": "owner_id_organization_id", + }, }, "meeting_t": { "unique_meeting_external_id": {"contype": "u", "fields": "external_id"}, + "idx_meeting_t_is_active_in_organization_id": { + "contype": None, + "field": "is_active_in_organization_id", + }, + "idx_meeting_t_is_archived_in_organization_id": { + "contype": None, + "field": "is_archived_in_organization_id", + }, + "idx_meeting_t_template_for_organization_id": { + "contype": None, + "field": "template_for_organization_id", + }, "unique_meeting_motions_default_workflow_id": { "contype": "u", "fields": "motions_default_workflow_id", @@ -302,6 +398,7 @@ "contype": "u", "fields": "font_projector_h2_id", }, + "idx_meeting_t_committee_id": {"contype": None, "field": "committee_id"}, "unique_meeting_reference_projector_id": { "contype": "u", "fields": "reference_projector_id", @@ -343,7 +440,12 @@ "contype": "u", "fields": "mediafile_id, meeting_id", "strict": False, - } + }, + "idx_meeting_mediafile_t_mediafile_id": { + "contype": None, + "field": "mediafile_id", + }, + "idx_meeting_mediafile_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "gm_meeting_mediafile_attachment_ids_t": { "unique_meeting_mediafile_id_attachment_id": { @@ -376,7 +478,13 @@ "contype": "u", "fields": "meeting_id, user_id", "strict": False, - } + }, + "idx_meeting_user_t_user_id": {"contype": None, "field": "user_id"}, + "idx_meeting_user_t_meeting_id": {"contype": None, "field": "meeting_id"}, + "idx_meeting_user_t_vote_delegated_to_id": { + "contype": None, + "field": "vote_delegated_to_id", + }, }, "nm_meeting_user_structure_level_ids_structure_level_t": { "pk_nm_meeting_user_structure_level_ids_structure_level_t": { @@ -402,6 +510,21 @@ "contype": "u", "fields": "sequential_number, meeting_id", }, + "idx_motion_t_lead_motion_id": {"contype": None, "field": "lead_motion_id"}, + "idx_motion_t_sort_parent_id": {"contype": None, "field": "sort_parent_id"}, + "idx_motion_t_origin_id": {"contype": None, "field": "origin_id"}, + "idx_motion_t_origin_meeting_id": { + "contype": None, + "field": "origin_meeting_id", + }, + "idx_motion_t_state_id": {"contype": None, "field": "state_id"}, + "idx_motion_t_recommendation_id": { + "contype": None, + "field": "recommendation_id", + }, + "idx_motion_t_category_id": {"contype": None, "field": "category_id"}, + "idx_motion_t_block_id": {"contype": None, "field": "block_id"}, + "idx_motion_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "nm_motion_all_derived_motion_ids_motion_t": { "pk_nm_motion_all_derived_motion_ids_motion_t": { @@ -471,40 +594,72 @@ "unique_motion_block_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_motion_block_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_category_t": { "unique_motion_category_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_motion_category_t_parent_id": {"contype": None, "field": "parent_id"}, + "idx_motion_category_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, + "motion_change_recommendation_t": { + "idx_motion_change_recommendation_t_motion_id": { + "contype": None, + "field": "motion_id", + }, + "idx_motion_change_recommendation_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, }, "motion_comment_t": { "unique_motion_comment_motion_id_section_id": { "contype": "u", "fields": "motion_id, section_id", "strict": False, - } + }, + "idx_motion_comment_t_motion_id": {"contype": None, "field": "motion_id"}, + "idx_motion_comment_t_section_id": {"contype": None, "field": "section_id"}, + "idx_motion_comment_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_comment_section_t": { "unique_motion_comment_section_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_motion_comment_section_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, }, "motion_editor_t": { "unique_motion_editor_meeting_user_id_motion_id": { "contype": "u", "fields": "meeting_user_id, motion_id", "strict": False, - } + }, + "idx_motion_editor_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_motion_editor_t_motion_id": {"contype": None, "field": "motion_id"}, + "idx_motion_editor_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_state_t": { "unique_motion_state_name_workflow_id": { "contype": "u", "fields": "name, workflow_id", "strict": False, - } + }, + "idx_motion_state_t_submitter_withdraw_state_id": { + "contype": None, + "field": "submitter_withdraw_state_id", + }, + "idx_motion_state_t_workflow_id": {"contype": None, "field": "workflow_id"}, + "idx_motion_state_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "nm_motion_state_next_state_ids_motion_state_t": { "pk_nm_motion_state_next_state_ids_motion_state_t": { @@ -525,14 +680,26 @@ "contype": "u", "fields": "meeting_user_id, motion_id", "strict": False, - } + }, + "idx_motion_submitter_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_motion_submitter_t_motion_id": {"contype": None, "field": "motion_id"}, + "idx_motion_submitter_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_supporter_t": { "unique_motion_supporter_meeting_user_id_motion_id": { "contype": "u", "fields": "meeting_user_id, motion_id", "strict": False, - } + }, + "idx_motion_supporter_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_motion_supporter_t_motion_id": {"contype": None, "field": "motion_id"}, + "idx_motion_supporter_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_workflow_t": { "unique_motion_workflow_sequential_number_meeting_id": { @@ -543,13 +710,26 @@ "contype": "u", "fields": "first_state_id", }, + "idx_motion_workflow_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "motion_working_group_speaker_t": { "unique_motion_working_group_speaker_meeting_user_id_motion_id": { "contype": "u", "fields": "meeting_user_id, motion_id", "strict": False, - } + }, + "idx_motion_working_group_speaker_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_motion_working_group_speaker_t_motion_id": { + "contype": None, + "field": "motion_id", + }, + "idx_motion_working_group_speaker_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, }, "option_t": { "unique_option_content_object_id_poll_id": { @@ -557,10 +737,20 @@ "fields": "content_object_id, poll_id", "strict": False, }, + "idx_option_t_poll_id": {"contype": None, "field": "poll_id"}, + "idx_option_t_content_object_id_motion_id": { + "contype": None, + "field": "content_object_id_motion_id", + }, + "idx_option_t_content_object_id_user_id": { + "contype": None, + "field": "content_object_id_user_id", + }, "unique_option_content_object_id_poll_candidate_list_id": { "contype": "u", "fields": "content_object_id_poll_candidate_list_id", }, + "idx_option_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "organization_t": { "unique_organization_theme_id": {"contype": "u", "fields": "theme_id"} @@ -587,11 +777,32 @@ "field": "tagged_id_meeting_id", }, }, + "organization_tag_t": { + "idx_organization_tag_t_organization_id": { + "contype": None, + "field": "organization_id", + } + }, "personal_note_t": { "unique_personal_note_meeting_user_id_content_object_id": { "contype": "u", "fields": "meeting_user_id, content_object_id", "strict": False, + }, + "idx_personal_note_t_meeting_user_id": { + "contype": None, + "field": "meeting_user_id", + }, + "idx_personal_note_t_content_object_id_motion_id": { + "contype": None, + "field": "content_object_id_motion_id", + }, + "idx_personal_note_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, + "point_of_order_category_t": { + "idx_point_of_order_category_t_meeting_id": { + "contype": None, + "field": "meeting_id", } }, "poll_t": { @@ -599,39 +810,215 @@ "contype": "u", "fields": "sequential_number, meeting_id", }, + "idx_poll_t_content_object_id_motion_id": { + "contype": None, + "field": "content_object_id_motion_id", + }, + "idx_poll_t_content_object_id_assignment_id": { + "contype": None, + "field": "content_object_id_assignment_id", + }, + "idx_poll_t_content_object_id_topic_id": { + "contype": None, + "field": "content_object_id_topic_id", + }, "unique_poll_global_option_id": {"contype": "u", "fields": "global_option_id"}, + "idx_poll_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "nm_poll_voted_ids_user_t": { "pk_nm_poll_voted_ids_user_t": {"contype": "p", "fields": "poll_id, user_id"}, "idx_nm_poll_voted_ids_user_t_poll_id": {"contype": None, "field": "poll_id"}, "idx_nm_poll_voted_ids_user_t_user_id": {"contype": None, "field": "user_id"}, }, + "poll_candidate_t": { + "idx_poll_candidate_t_poll_candidate_list_id": { + "contype": None, + "field": "poll_candidate_list_id", + }, + "idx_poll_candidate_t_user_id": {"contype": None, "field": "user_id"}, + "idx_poll_candidate_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, + "poll_candidate_list_t": { + "idx_poll_candidate_list_t_meeting_id": {"contype": None, "field": "meeting_id"} + }, + "projection_t": { + "idx_projection_t_current_projector_id": { + "contype": None, + "field": "current_projector_id", + }, + "idx_projection_t_preview_projector_id": { + "contype": None, + "field": "preview_projector_id", + }, + "idx_projection_t_history_projector_id": { + "contype": None, + "field": "history_projector_id", + }, + "idx_projection_t_content_object_id_meeting_id": { + "contype": None, + "field": "content_object_id_meeting_id", + }, + "idx_projection_t_content_object_id_motion_id": { + "contype": None, + "field": "content_object_id_motion_id", + }, + "idx_projection_t_content_object_id_meeting_mediafile_id": { + "contype": None, + "field": "content_object_id_meeting_mediafile_id", + }, + "idx_projection_t_content_object_id_list_of_speakers_id": { + "contype": None, + "field": "content_object_id_list_of_speakers_id", + }, + "idx_projection_t_content_object_id_motion_block_id": { + "contype": None, + "field": "content_object_id_motion_block_id", + }, + "idx_projection_t_content_object_id_assignment_id": { + "contype": None, + "field": "content_object_id_assignment_id", + }, + "idx_projection_t_content_object_id_agenda_item_id": { + "contype": None, + "field": "content_object_id_agenda_item_id", + }, + "idx_projection_t_content_object_id_topic_id": { + "contype": None, + "field": "content_object_id_topic_id", + }, + "idx_projection_t_content_object_id_poll_id": { + "contype": None, + "field": "content_object_id_poll_id", + }, + "idx_projection_t_content_object_id_projector_message_id": { + "contype": None, + "field": "content_object_id_projector_message_id", + }, + "idx_projection_t_content_object_id_projector_countdown_id": { + "contype": None, + "field": "content_object_id_projector_countdown_id", + }, + "idx_projection_t_meeting_id": {"contype": None, "field": "meeting_id"}, + }, "projector_t": { "unique_projector_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_projector_t_used_as_default_projector_for_agenda_ite41b5bd9": { + "contype": None, + "field": "used_as_default_projector_for_agenda_item_list_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_topic_in_mab361e8": { + "contype": None, + "field": "used_as_default_projector_for_topic_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_list_of_spb099704": { + "contype": None, + "field": "used_as_default_projector_for_list_of_speakers_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_current_locdd5b27": { + "contype": None, + "field": "used_as_default_projector_for_current_los_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_motion_in_f66691f": { + "contype": None, + "field": "used_as_default_projector_for_motion_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_amendment_2235e12": { + "contype": None, + "field": "used_as_default_projector_for_amendment_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_motion_blo7b0c3c8": { + "contype": None, + "field": "used_as_default_projector_for_motion_block_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_assignment78622ce": { + "contype": None, + "field": "used_as_default_projector_for_assignment_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_mediafile_1c31a99": { + "contype": None, + "field": "used_as_default_projector_for_mediafile_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_message_in339958e": { + "contype": None, + "field": "used_as_default_projector_for_message_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_countdown_07665b4": { + "contype": None, + "field": "used_as_default_projector_for_countdown_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_assignment5a08584": { + "contype": None, + "field": "used_as_default_projector_for_assignment_poll_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_motion_pol0605aa8": { + "contype": None, + "field": "used_as_default_projector_for_motion_poll_in_meeting_id", + }, + "idx_projector_t_used_as_default_projector_for_poll_in_me446bdba": { + "contype": None, + "field": "used_as_default_projector_for_poll_in_meeting_id", + }, + "idx_projector_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "projector_countdown_t": { "unique_projector_countdown_meeting_id_title": { "contype": "u", "fields": "meeting_id, title", "strict": False, - } + }, + "idx_projector_countdown_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, + }, + "projector_message_t": { + "idx_projector_message_t_meeting_id": {"contype": None, "field": "meeting_id"} + }, + "speaker_t": { + "idx_speaker_t_list_of_speakers_id": { + "contype": None, + "field": "list_of_speakers_id", + }, + "idx_speaker_t_structure_level_list_of_speakers_id": { + "contype": None, + "field": "structure_level_list_of_speakers_id", + }, + "idx_speaker_t_meeting_user_id": {"contype": None, "field": "meeting_user_id"}, + "idx_speaker_t_point_of_order_category_id": { + "contype": None, + "field": "point_of_order_category_id", + }, + "idx_speaker_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "structure_level_t": { "unique_structure_level_meeting_id_name": { "contype": "u", "fields": "meeting_id, name", "strict": False, - } + }, + "idx_structure_level_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "structure_level_list_of_speakers_t": { "unique_structure_level_list_of_speakers_meeting_id_struce047abe": { "contype": "u", "fields": "meeting_id, structure_level_id, list_of_speakers_id", "strict": False, - } + }, + "idx_structure_level_list_of_speakers_t_structure_level_id": { + "contype": None, + "field": "structure_level_id", + }, + "idx_structure_level_list_of_speakers_t_list_of_speakers_id": { + "contype": None, + "field": "list_of_speakers_id", + }, + "idx_structure_level_list_of_speakers_t_meeting_id": { + "contype": None, + "field": "meeting_id", + }, }, "gm_tag_tagged_ids_t": { "unique_tag_id_tagged_id": {"contype": "u", "fields": "tag_id, tagged_id"}, @@ -650,15 +1037,29 @@ "field": "tagged_id_motion_id", }, }, + "tag_t": {"idx_tag_t_meeting_id": {"contype": None, "field": "meeting_id"}}, + "theme_t": { + "idx_theme_t_organization_id": {"contype": None, "field": "organization_id"} + }, "topic_t": { "unique_topic_sequential_number_meeting_id": { "contype": "u", "fields": "sequential_number, meeting_id", - } + }, + "idx_topic_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, "user_t": { "unique_user_username": {"contype": "u", "fields": "username"}, "unique_user_member_number": {"contype": "u", "fields": "member_number"}, "unique_user_saml_id": {"contype": "u", "fields": "saml_id"}, + "idx_user_t_gender_id": {"contype": None, "field": "gender_id"}, + "idx_user_t_home_committee_id": {"contype": None, "field": "home_committee_id"}, + "idx_user_t_organization_id": {"contype": None, "field": "organization_id"}, + }, + "vote_t": { + "idx_vote_t_option_id": {"contype": None, "field": "option_id"}, + "idx_vote_t_user_id": {"contype": None, "field": "user_id"}, + "idx_vote_t_delegated_user_id": {"contype": None, "field": "delegated_user_id"}, + "idx_vote_t_meeting_id": {"contype": None, "field": "meeting_id"}, }, } diff --git a/tests/system/migrations/test_0103_update_indexes.py b/tests/system/migrations/test_0103_update_indexes.py index 0b231ade37..f18547c01b 100644 --- a/tests/system/migrations/test_0103_update_indexes.py +++ b/tests/system/migrations/test_0103_update_indexes.py @@ -249,3 +249,24 @@ def test_0103(self) -> None: WHERE indexname = '{index}'; """).fetchone() assert row == {"on_columns": index.split("_t_")[1]} + + # Check correct primary keys not dropped + for pk in [ + "pk_nm_motion_identical_motion_ids_motion_t", + "committee_t_pkey", + ]: + self.assert_table_constraint_exists(curs, pk) + + # Check indexes from schema not dropped + for index in [ + "idx_nm_committee_all_child_ids_committee_t_all_parent_id", + "idx_nm_committee_all_child_ids_committee_t_all_child_id", + "idx_gm_motion_recommendation_extension_reference_ids_t_m81631d0", + "idx_gm_motion_recommendation_extension_reference_ids_t_r6488b59", + "idx_gm_motion_recommendation_extension_reference_ids_t_r1489537", + "idx_history_entry_t_model_id_user_id", + "idx_history_entry_t_model_id_motion_id", + "idx_history_entry_t_model_id_assignment_id", + "idx_history_entry_t_position_id", + ]: + self.assert_index_exists(curs, index)