|
| 1 | +/* Copyright 2022 The Matrix.org Foundation C.I.C |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +-- SQLite needs to rebuild indices which use partial indices on Postgres, but |
| 17 | +-- previously did not use them on SQLite. |
| 18 | + |
| 19 | +-- Drop each index that was added with register_background_index_update AND specified |
| 20 | +-- a where_clause (that existed before this delta). |
| 21 | + |
| 22 | +-- From events_bg_updates.py |
| 23 | +DROP INDEX IF EXISTS event_contains_url_index; |
| 24 | +-- There is also a redactions_censored_redacts index, but that gets dropped. |
| 25 | +DROP INDEX IF EXISTS redactions_have_censored_ts; |
| 26 | +-- There is also a PostgreSQL only index (event_contains_url_index2) |
| 27 | +-- which gets renamed to event_contains_url_index. |
| 28 | + |
| 29 | +-- From roommember.py |
| 30 | +DROP INDEX IF EXISTS room_memberships_user_room_forgotten; |
| 31 | + |
| 32 | +-- From presence.py |
| 33 | +DROP INDEX IF EXISTS presence_stream_state_not_offline_idx; |
| 34 | + |
| 35 | +-- From media_repository.py |
| 36 | +DROP INDEX IF EXISTS local_media_repository_url_idx; |
| 37 | + |
| 38 | +-- From event_push_actions.py |
| 39 | +DROP INDEX IF EXISTS event_push_actions_highlights_index; |
| 40 | +-- There's also a event_push_actions_stream_highlight_index which was previously |
| 41 | +-- PostgreSQL-only. |
| 42 | + |
| 43 | +-- From state.py |
| 44 | +DROP INDEX IF EXISTS current_state_events_member_index; |
| 45 | + |
| 46 | +-- Re-insert the background jobs to re-create the indices. |
| 47 | +INSERT INTO background_updates (ordering, update_name, progress_json, depends_on) VALUES |
| 48 | + (7209, 'event_contains_url_index', '{}', NULL), |
| 49 | + (7209, 'redactions_have_censored_ts_idx', '{}', NULL), |
| 50 | + (7209, 'room_membership_forgotten_idx', '{}', NULL), |
| 51 | + (7209, 'presence_stream_not_offline_index', '{}', NULL), |
| 52 | + (7209, 'local_media_repository_url_idx', '{}', NULL), |
| 53 | + (7209, 'event_push_actions_highlights_index', '{}', NULL), |
| 54 | + (7209, 'event_push_actions_stream_highlight_index', '{}', NULL), |
| 55 | + (7209, 'current_state_members_idx', '{}', NULL) |
| 56 | +ON CONFLICT (update_name) DO NOTHING; |
0 commit comments