|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 7 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 8 | + */ |
| 9 | + |
| 10 | +namespace OC\Core\Listener; |
| 11 | + |
| 12 | +use OCP\DB\Events\AddMissingIndicesEvent; |
| 13 | +use OCP\EventDispatcher\Event; |
| 14 | +use OCP\EventDispatcher\IEventListener; |
| 15 | + |
| 16 | +/** |
| 17 | + * @template-implements IEventListener<AddMissingIndicesEvent> |
| 18 | + */ |
| 19 | +class AddMissingIndicesListener implements IEventListener { |
| 20 | + |
| 21 | + public function handle(Event $event): void { |
| 22 | + if (!($event instanceof AddMissingIndicesEvent)) { |
| 23 | + return; |
| 24 | + } |
| 25 | + |
| 26 | + $event->addMissingIndex( |
| 27 | + 'share', |
| 28 | + 'share_with_index', |
| 29 | + ['share_with'] |
| 30 | + ); |
| 31 | + $event->addMissingIndex( |
| 32 | + 'share', |
| 33 | + 'parent_index', |
| 34 | + ['parent'] |
| 35 | + ); |
| 36 | + $event->addMissingIndex( |
| 37 | + 'share', |
| 38 | + 'owner_index', |
| 39 | + ['uid_owner'] |
| 40 | + ); |
| 41 | + $event->addMissingIndex( |
| 42 | + 'share', |
| 43 | + 'initiator_index', |
| 44 | + ['uid_initiator'] |
| 45 | + ); |
| 46 | + |
| 47 | + $event->addMissingIndex( |
| 48 | + 'filecache', |
| 49 | + 'fs_mtime', |
| 50 | + ['mtime'] |
| 51 | + ); |
| 52 | + $event->addMissingIndex( |
| 53 | + 'filecache', |
| 54 | + 'fs_size', |
| 55 | + ['size'] |
| 56 | + ); |
| 57 | + $event->addMissingIndex( |
| 58 | + 'filecache', |
| 59 | + 'fs_storage_path_prefix', |
| 60 | + ['storage', 'path'], |
| 61 | + ['lengths' => [null, 64]] |
| 62 | + ); |
| 63 | + $event->addMissingIndex( |
| 64 | + 'filecache', |
| 65 | + 'fs_parent', |
| 66 | + ['parent'] |
| 67 | + ); |
| 68 | + $event->addMissingIndex( |
| 69 | + 'filecache', |
| 70 | + 'fs_name_hash', |
| 71 | + ['name'] |
| 72 | + ); |
| 73 | + |
| 74 | + $event->addMissingIndex( |
| 75 | + 'twofactor_providers', |
| 76 | + 'twofactor_providers_uid', |
| 77 | + ['uid'] |
| 78 | + ); |
| 79 | + |
| 80 | + $event->addMissingUniqueIndex( |
| 81 | + 'login_flow_v2', |
| 82 | + 'poll_token', |
| 83 | + ['poll_token'], |
| 84 | + [], |
| 85 | + true |
| 86 | + ); |
| 87 | + $event->addMissingUniqueIndex( |
| 88 | + 'login_flow_v2', |
| 89 | + 'login_token', |
| 90 | + ['login_token'], |
| 91 | + [], |
| 92 | + true |
| 93 | + ); |
| 94 | + $event->addMissingIndex( |
| 95 | + 'login_flow_v2', |
| 96 | + 'timestamp', |
| 97 | + ['timestamp'], |
| 98 | + [], |
| 99 | + true |
| 100 | + ); |
| 101 | + |
| 102 | + $event->addMissingIndex( |
| 103 | + 'whats_new', |
| 104 | + 'version', |
| 105 | + ['version'], |
| 106 | + [], |
| 107 | + true |
| 108 | + ); |
| 109 | + |
| 110 | + $event->addMissingIndex( |
| 111 | + 'cards', |
| 112 | + 'cards_abiduri', |
| 113 | + ['addressbookid', 'uri'], |
| 114 | + [], |
| 115 | + true |
| 116 | + ); |
| 117 | + |
| 118 | + $event->replaceIndex( |
| 119 | + 'cards_properties', |
| 120 | + ['cards_prop_abid'], |
| 121 | + 'cards_prop_abid_name_value', |
| 122 | + ['addressbookid', 'name', 'value'], |
| 123 | + false, |
| 124 | + ); |
| 125 | + |
| 126 | + $event->addMissingIndex( |
| 127 | + 'calendarobjects_props', |
| 128 | + 'calendarobject_calid_index', |
| 129 | + ['calendarid', 'calendartype'] |
| 130 | + ); |
| 131 | + |
| 132 | + $event->addMissingIndex( |
| 133 | + 'schedulingobjects', |
| 134 | + 'schedulobj_principuri_index', |
| 135 | + ['principaluri'] |
| 136 | + ); |
| 137 | + |
| 138 | + $event->addMissingIndex( |
| 139 | + 'schedulingobjects', |
| 140 | + 'schedulobj_lastmodified_idx', |
| 141 | + ['lastmodified'] |
| 142 | + ); |
| 143 | + |
| 144 | + $event->addMissingIndex( |
| 145 | + 'properties', |
| 146 | + 'properties_path_index', |
| 147 | + ['userid', 'propertypath'] |
| 148 | + ); |
| 149 | + $event->addMissingIndex( |
| 150 | + 'properties', |
| 151 | + 'properties_pathonly_index', |
| 152 | + ['propertypath'] |
| 153 | + ); |
| 154 | + $event->addMissingIndex( |
| 155 | + 'properties', |
| 156 | + 'properties_name_path_user', |
| 157 | + ['propertyname', 'propertypath', 'userid'] |
| 158 | + ); |
| 159 | + |
| 160 | + |
| 161 | + $event->addMissingIndex( |
| 162 | + 'jobs', |
| 163 | + 'job_lastcheck_reserved', |
| 164 | + ['last_checked', 'reserved_at'] |
| 165 | + ); |
| 166 | + |
| 167 | + $event->addMissingIndex( |
| 168 | + 'direct_edit', |
| 169 | + 'direct_edit_timestamp', |
| 170 | + ['timestamp'] |
| 171 | + ); |
| 172 | + |
| 173 | + $event->addMissingIndex( |
| 174 | + 'preferences', |
| 175 | + 'prefs_uid_lazy_i', |
| 176 | + ['userid', 'lazy'] |
| 177 | + ); |
| 178 | + $event->addMissingIndex( |
| 179 | + 'preferences', |
| 180 | + 'prefs_app_key_ind_fl_i', |
| 181 | + ['appid', 'configkey', 'indexed', 'flags'] |
| 182 | + ); |
| 183 | + |
| 184 | + $event->addMissingIndex( |
| 185 | + 'mounts', |
| 186 | + 'mounts_class_index', |
| 187 | + ['mount_provider_class'] |
| 188 | + ); |
| 189 | + $event->addMissingIndex( |
| 190 | + 'mounts', |
| 191 | + 'mounts_user_root_path_index', |
| 192 | + ['user_id', 'root_id', 'mount_point'], |
| 193 | + ['lengths' => [null, null, 128]] |
| 194 | + ); |
| 195 | + |
| 196 | + $event->addMissingIndex( |
| 197 | + 'systemtag_object_mapping', |
| 198 | + 'systag_by_tagid', |
| 199 | + ['systemtagid', 'objecttype'] |
| 200 | + ); |
| 201 | + |
| 202 | + $event->addMissingIndex( |
| 203 | + 'systemtag_object_mapping', |
| 204 | + 'systag_by_objectid', |
| 205 | + ['objectid'] |
| 206 | + ); |
| 207 | + |
| 208 | + $event->addMissingIndex( |
| 209 | + 'systemtag_object_mapping', |
| 210 | + 'systag_objecttype', |
| 211 | + ['objecttype'] |
| 212 | + ); |
| 213 | + |
| 214 | + $event->addMissingUniqueIndex( |
| 215 | + 'vcategory', |
| 216 | + 'unique_category_per_user', |
| 217 | + ['uid', 'type', 'category'] |
| 218 | + ); |
| 219 | + } |
| 220 | +} |
0 commit comments