@@ -50,226 +50,226 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | class AddMissingIndices extends Command { |
| 52 | 52 | |
| 53 | - /** @var IDBConnection */ |
|
| 54 | - private $connection; |
|
| 55 | - |
|
| 56 | - /** @var EventDispatcherInterface */ |
|
| 57 | - private $dispatcher; |
|
| 58 | - |
|
| 59 | - public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { |
|
| 60 | - parent::__construct(); |
|
| 61 | - |
|
| 62 | - $this->connection = $connection; |
|
| 63 | - $this->dispatcher = $dispatcher; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - protected function configure() { |
|
| 67 | - $this |
|
| 68 | - ->setName('db:add-missing-indices') |
|
| 69 | - ->setDescription('Add missing indices to the database tables'); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 73 | - $this->addCoreIndexes($output); |
|
| 74 | - |
|
| 75 | - // Dispatch event so apps can also update indexes if needed |
|
| 76 | - $event = new GenericEvent($output); |
|
| 77 | - $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * add missing indices to the share table |
|
| 82 | - * |
|
| 83 | - * @param OutputInterface $output |
|
| 84 | - * @throws \Doctrine\DBAL\Schema\SchemaException |
|
| 85 | - */ |
|
| 86 | - private function addCoreIndexes(OutputInterface $output) { |
|
| 87 | - $output->writeln('<info>Check indices of the share table.</info>'); |
|
| 88 | - |
|
| 89 | - $schema = new SchemaWrapper($this->connection); |
|
| 90 | - $updated = false; |
|
| 91 | - |
|
| 92 | - if ($schema->hasTable('share')) { |
|
| 93 | - $table = $schema->getTable('share'); |
|
| 94 | - if (!$table->hasIndex('share_with_index')) { |
|
| 95 | - $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>'); |
|
| 96 | - $table->addIndex(['share_with'], 'share_with_index'); |
|
| 97 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 98 | - $updated = true; |
|
| 99 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - if (!$table->hasIndex('parent_index')) { |
|
| 103 | - $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>'); |
|
| 104 | - $table->addIndex(['parent'], 'parent_index'); |
|
| 105 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 106 | - $updated = true; |
|
| 107 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if (!$table->hasIndex('owner_index')) { |
|
| 111 | - $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>'); |
|
| 112 | - $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 113 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 114 | - $updated = true; |
|
| 115 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if (!$table->hasIndex('initiator_index')) { |
|
| 119 | - $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>'); |
|
| 120 | - $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 121 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 122 | - $updated = true; |
|
| 123 | - $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $output->writeln('<info>Check indices of the filecache table.</info>'); |
|
| 128 | - if ($schema->hasTable('filecache')) { |
|
| 129 | - $table = $schema->getTable('filecache'); |
|
| 130 | - if (!$table->hasIndex('fs_mtime')) { |
|
| 131 | - $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>'); |
|
| 132 | - $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 133 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 134 | - $updated = true; |
|
| 135 | - $output->writeln('<info>Filecache table updated successfully.</info>'); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - $output->writeln('<info>Check indices of the twofactor_providers table.</info>'); |
|
| 140 | - if ($schema->hasTable('twofactor_providers')) { |
|
| 141 | - $table = $schema->getTable('twofactor_providers'); |
|
| 142 | - if (!$table->hasIndex('twofactor_providers_uid')) { |
|
| 143 | - $output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>'); |
|
| 144 | - $table->addIndex(['uid'], 'twofactor_providers_uid'); |
|
| 145 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 146 | - $updated = true; |
|
| 147 | - $output->writeln('<info>Twofactor_providers table updated successfully.</info>'); |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - $output->writeln('<info>Check indices of the login_flow_v2 table.</info>'); |
|
| 152 | - if ($schema->hasTable('login_flow_v2')) { |
|
| 153 | - $table = $schema->getTable('login_flow_v2'); |
|
| 154 | - if (!$table->hasIndex('poll_token')) { |
|
| 155 | - $output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>'); |
|
| 156 | - |
|
| 157 | - foreach ($table->getIndexes() as $index) { |
|
| 158 | - $columns = $index->getColumns(); |
|
| 159 | - if ($columns === ['poll_token'] || |
|
| 160 | - $columns === ['login_token'] || |
|
| 161 | - $columns === ['timestamp']) { |
|
| 162 | - $table->dropIndex($index->getName()); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
| 167 | - $table->addUniqueIndex(['login_token'], 'login_token'); |
|
| 168 | - $table->addIndex(['timestamp'], 'timestamp'); |
|
| 169 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 170 | - $updated = true; |
|
| 171 | - $output->writeln('<info>login_flow_v2 table updated successfully.</info>'); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $output->writeln('<info>Check indices of the whats_new table.</info>'); |
|
| 176 | - if ($schema->hasTable('whats_new')) { |
|
| 177 | - $table = $schema->getTable('whats_new'); |
|
| 178 | - if (!$table->hasIndex('version')) { |
|
| 179 | - $output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>'); |
|
| 180 | - |
|
| 181 | - foreach ($table->getIndexes() as $index) { |
|
| 182 | - if ($index->getColumns() === ['version']) { |
|
| 183 | - $table->dropIndex($index->getName()); |
|
| 184 | - } |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $table->addUniqueIndex(['version'], 'version'); |
|
| 188 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 189 | - $updated = true; |
|
| 190 | - $output->writeln('<info>whats_new table updated successfully.</info>'); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $output->writeln('<info>Check indices of the cards table.</info>'); |
|
| 195 | - if ($schema->hasTable('cards')) { |
|
| 196 | - $table = $schema->getTable('cards'); |
|
| 197 | - if (!$table->hasIndex('cards_abid')) { |
|
| 198 | - $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>'); |
|
| 199 | - |
|
| 200 | - foreach ($table->getIndexes() as $index) { |
|
| 201 | - if ($index->getColumns() === ['addressbookid']) { |
|
| 202 | - $table->dropIndex($index->getName()); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - $table->addIndex(['addressbookid'], 'cards_abid'); |
|
| 207 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 208 | - $updated = true; |
|
| 209 | - $output->writeln('<info>cards table updated successfully.</info>'); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $output->writeln('<info>Check indices of the cards_properties table.</info>'); |
|
| 214 | - if ($schema->hasTable('cards_properties')) { |
|
| 215 | - $table = $schema->getTable('cards_properties'); |
|
| 216 | - if (!$table->hasIndex('cards_prop_abid')) { |
|
| 217 | - $output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>'); |
|
| 218 | - |
|
| 219 | - foreach ($table->getIndexes() as $index) { |
|
| 220 | - if ($index->getColumns() === ['addressbookid']) { |
|
| 221 | - $table->dropIndex($index->getName()); |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $table->addIndex(['addressbookid'], 'cards_prop_abid'); |
|
| 226 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 227 | - $updated = true; |
|
| 228 | - $output->writeln('<info>cards_properties table updated successfully.</info>'); |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - $output->writeln('<info>Check indices of the calendarobjects_props table.</info>'); |
|
| 233 | - if ($schema->hasTable('calendarobjects_props')) { |
|
| 234 | - $table = $schema->getTable('calendarobjects_props'); |
|
| 235 | - if (!$table->hasIndex('calendarobject_calid_index')) { |
|
| 236 | - $output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>'); |
|
| 237 | - |
|
| 238 | - $table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index'); |
|
| 239 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 240 | - $updated = true; |
|
| 241 | - $output->writeln('<info>calendarobjects_props table updated successfully.</info>'); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - $output->writeln('<info>Check indices of the schedulingobjects table.</info>'); |
|
| 246 | - if ($schema->hasTable('schedulingobjects')) { |
|
| 247 | - $table = $schema->getTable('schedulingobjects'); |
|
| 248 | - if (!$table->hasIndex('schedulobj_principuri_index')) { |
|
| 249 | - $output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>'); |
|
| 250 | - |
|
| 251 | - $table->addIndex(['principaluri'], 'schedulobj_principuri_index'); |
|
| 252 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 253 | - $updated = true; |
|
| 254 | - $output->writeln('<info>schedulingobjects table updated successfully.</info>'); |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - $output->writeln('<info>Check indices of the oc_properties table.</info>'); |
|
| 259 | - if ($schema->hasTable('properties')) { |
|
| 260 | - $table = $schema->getTable('properties'); |
|
| 261 | - if (!$table->hasIndex('properties_path_index')) { |
|
| 262 | - $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>'); |
|
| 263 | - |
|
| 264 | - $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 265 | - $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 266 | - $updated = true; |
|
| 267 | - $output->writeln('<info>oc_properties table updated successfully.</info>'); |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if (!$updated) { |
|
| 272 | - $output->writeln('<info>Done.</info>'); |
|
| 273 | - } |
|
| 274 | - } |
|
| 53 | + /** @var IDBConnection */ |
|
| 54 | + private $connection; |
|
| 55 | + |
|
| 56 | + /** @var EventDispatcherInterface */ |
|
| 57 | + private $dispatcher; |
|
| 58 | + |
|
| 59 | + public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { |
|
| 60 | + parent::__construct(); |
|
| 61 | + |
|
| 62 | + $this->connection = $connection; |
|
| 63 | + $this->dispatcher = $dispatcher; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + protected function configure() { |
|
| 67 | + $this |
|
| 68 | + ->setName('db:add-missing-indices') |
|
| 69 | + ->setDescription('Add missing indices to the database tables'); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 73 | + $this->addCoreIndexes($output); |
|
| 74 | + |
|
| 75 | + // Dispatch event so apps can also update indexes if needed |
|
| 76 | + $event = new GenericEvent($output); |
|
| 77 | + $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_INDEXES_EVENT, $event); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * add missing indices to the share table |
|
| 82 | + * |
|
| 83 | + * @param OutputInterface $output |
|
| 84 | + * @throws \Doctrine\DBAL\Schema\SchemaException |
|
| 85 | + */ |
|
| 86 | + private function addCoreIndexes(OutputInterface $output) { |
|
| 87 | + $output->writeln('<info>Check indices of the share table.</info>'); |
|
| 88 | + |
|
| 89 | + $schema = new SchemaWrapper($this->connection); |
|
| 90 | + $updated = false; |
|
| 91 | + |
|
| 92 | + if ($schema->hasTable('share')) { |
|
| 93 | + $table = $schema->getTable('share'); |
|
| 94 | + if (!$table->hasIndex('share_with_index')) { |
|
| 95 | + $output->writeln('<info>Adding additional share_with index to the share table, this can take some time...</info>'); |
|
| 96 | + $table->addIndex(['share_with'], 'share_with_index'); |
|
| 97 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 98 | + $updated = true; |
|
| 99 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + if (!$table->hasIndex('parent_index')) { |
|
| 103 | + $output->writeln('<info>Adding additional parent index to the share table, this can take some time...</info>'); |
|
| 104 | + $table->addIndex(['parent'], 'parent_index'); |
|
| 105 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 106 | + $updated = true; |
|
| 107 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if (!$table->hasIndex('owner_index')) { |
|
| 111 | + $output->writeln('<info>Adding additional owner index to the share table, this can take some time...</info>'); |
|
| 112 | + $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 113 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 114 | + $updated = true; |
|
| 115 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + if (!$table->hasIndex('initiator_index')) { |
|
| 119 | + $output->writeln('<info>Adding additional initiator index to the share table, this can take some time...</info>'); |
|
| 120 | + $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 121 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 122 | + $updated = true; |
|
| 123 | + $output->writeln('<info>Share table updated successfully.</info>'); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $output->writeln('<info>Check indices of the filecache table.</info>'); |
|
| 128 | + if ($schema->hasTable('filecache')) { |
|
| 129 | + $table = $schema->getTable('filecache'); |
|
| 130 | + if (!$table->hasIndex('fs_mtime')) { |
|
| 131 | + $output->writeln('<info>Adding additional mtime index to the filecache table, this can take some time...</info>'); |
|
| 132 | + $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 133 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 134 | + $updated = true; |
|
| 135 | + $output->writeln('<info>Filecache table updated successfully.</info>'); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + $output->writeln('<info>Check indices of the twofactor_providers table.</info>'); |
|
| 140 | + if ($schema->hasTable('twofactor_providers')) { |
|
| 141 | + $table = $schema->getTable('twofactor_providers'); |
|
| 142 | + if (!$table->hasIndex('twofactor_providers_uid')) { |
|
| 143 | + $output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>'); |
|
| 144 | + $table->addIndex(['uid'], 'twofactor_providers_uid'); |
|
| 145 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 146 | + $updated = true; |
|
| 147 | + $output->writeln('<info>Twofactor_providers table updated successfully.</info>'); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + $output->writeln('<info>Check indices of the login_flow_v2 table.</info>'); |
|
| 152 | + if ($schema->hasTable('login_flow_v2')) { |
|
| 153 | + $table = $schema->getTable('login_flow_v2'); |
|
| 154 | + if (!$table->hasIndex('poll_token')) { |
|
| 155 | + $output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>'); |
|
| 156 | + |
|
| 157 | + foreach ($table->getIndexes() as $index) { |
|
| 158 | + $columns = $index->getColumns(); |
|
| 159 | + if ($columns === ['poll_token'] || |
|
| 160 | + $columns === ['login_token'] || |
|
| 161 | + $columns === ['timestamp']) { |
|
| 162 | + $table->dropIndex($index->getName()); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + $table->addUniqueIndex(['poll_token'], 'poll_token'); |
|
| 167 | + $table->addUniqueIndex(['login_token'], 'login_token'); |
|
| 168 | + $table->addIndex(['timestamp'], 'timestamp'); |
|
| 169 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 170 | + $updated = true; |
|
| 171 | + $output->writeln('<info>login_flow_v2 table updated successfully.</info>'); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $output->writeln('<info>Check indices of the whats_new table.</info>'); |
|
| 176 | + if ($schema->hasTable('whats_new')) { |
|
| 177 | + $table = $schema->getTable('whats_new'); |
|
| 178 | + if (!$table->hasIndex('version')) { |
|
| 179 | + $output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>'); |
|
| 180 | + |
|
| 181 | + foreach ($table->getIndexes() as $index) { |
|
| 182 | + if ($index->getColumns() === ['version']) { |
|
| 183 | + $table->dropIndex($index->getName()); |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $table->addUniqueIndex(['version'], 'version'); |
|
| 188 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 189 | + $updated = true; |
|
| 190 | + $output->writeln('<info>whats_new table updated successfully.</info>'); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $output->writeln('<info>Check indices of the cards table.</info>'); |
|
| 195 | + if ($schema->hasTable('cards')) { |
|
| 196 | + $table = $schema->getTable('cards'); |
|
| 197 | + if (!$table->hasIndex('cards_abid')) { |
|
| 198 | + $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>'); |
|
| 199 | + |
|
| 200 | + foreach ($table->getIndexes() as $index) { |
|
| 201 | + if ($index->getColumns() === ['addressbookid']) { |
|
| 202 | + $table->dropIndex($index->getName()); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + $table->addIndex(['addressbookid'], 'cards_abid'); |
|
| 207 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 208 | + $updated = true; |
|
| 209 | + $output->writeln('<info>cards table updated successfully.</info>'); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $output->writeln('<info>Check indices of the cards_properties table.</info>'); |
|
| 214 | + if ($schema->hasTable('cards_properties')) { |
|
| 215 | + $table = $schema->getTable('cards_properties'); |
|
| 216 | + if (!$table->hasIndex('cards_prop_abid')) { |
|
| 217 | + $output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>'); |
|
| 218 | + |
|
| 219 | + foreach ($table->getIndexes() as $index) { |
|
| 220 | + if ($index->getColumns() === ['addressbookid']) { |
|
| 221 | + $table->dropIndex($index->getName()); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $table->addIndex(['addressbookid'], 'cards_prop_abid'); |
|
| 226 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 227 | + $updated = true; |
|
| 228 | + $output->writeln('<info>cards_properties table updated successfully.</info>'); |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + $output->writeln('<info>Check indices of the calendarobjects_props table.</info>'); |
|
| 233 | + if ($schema->hasTable('calendarobjects_props')) { |
|
| 234 | + $table = $schema->getTable('calendarobjects_props'); |
|
| 235 | + if (!$table->hasIndex('calendarobject_calid_index')) { |
|
| 236 | + $output->writeln('<info>Adding calendarobject_calid_index index to the calendarobjects_props table, this can take some time...</info>'); |
|
| 237 | + |
|
| 238 | + $table->addIndex(['calendarid', 'calendartype'], 'calendarobject_calid_index'); |
|
| 239 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 240 | + $updated = true; |
|
| 241 | + $output->writeln('<info>calendarobjects_props table updated successfully.</info>'); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + $output->writeln('<info>Check indices of the schedulingobjects table.</info>'); |
|
| 246 | + if ($schema->hasTable('schedulingobjects')) { |
|
| 247 | + $table = $schema->getTable('schedulingobjects'); |
|
| 248 | + if (!$table->hasIndex('schedulobj_principuri_index')) { |
|
| 249 | + $output->writeln('<info>Adding schedulobj_principuri_index index to the schedulingobjects table, this can take some time...</info>'); |
|
| 250 | + |
|
| 251 | + $table->addIndex(['principaluri'], 'schedulobj_principuri_index'); |
|
| 252 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 253 | + $updated = true; |
|
| 254 | + $output->writeln('<info>schedulingobjects table updated successfully.</info>'); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + $output->writeln('<info>Check indices of the oc_properties table.</info>'); |
|
| 259 | + if ($schema->hasTable('properties')) { |
|
| 260 | + $table = $schema->getTable('properties'); |
|
| 261 | + if (!$table->hasIndex('properties_path_index')) { |
|
| 262 | + $output->writeln('<info>Adding properties_path_index index to the oc_properties table, this can take some time...</info>'); |
|
| 263 | + |
|
| 264 | + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 265 | + $this->connection->migrateToSchema($schema->getWrappedSchema()); |
|
| 266 | + $updated = true; |
|
| 267 | + $output->writeln('<info>oc_properties table updated successfully.</info>'); |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if (!$updated) { |
|
| 272 | + $output->writeln('<info>Done.</info>'); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | } |
@@ -35,902 +35,902 @@ |
||
| 35 | 35 | |
| 36 | 36 | class Version13000Date20170718121200 extends SimpleMigrationStep { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param IOutput $output |
|
| 40 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | - * @param array $options |
|
| 42 | - * @return null|ISchemaWrapper |
|
| 43 | - * @since 13.0.0 |
|
| 44 | - */ |
|
| 45 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 46 | - /** @var ISchemaWrapper $schema */ |
|
| 47 | - $schema = $schemaClosure(); |
|
| 48 | - |
|
| 49 | - if (!$schema->hasTable('appconfig')) { |
|
| 50 | - $table = $schema->createTable('appconfig'); |
|
| 51 | - $table->addColumn('appid', 'string', [ |
|
| 52 | - 'notnull' => true, |
|
| 53 | - 'length' => 32, |
|
| 54 | - 'default' => '', |
|
| 55 | - ]); |
|
| 56 | - $table->addColumn('configkey', 'string', [ |
|
| 57 | - 'notnull' => true, |
|
| 58 | - 'length' => 64, |
|
| 59 | - 'default' => '', |
|
| 60 | - ]); |
|
| 61 | - $table->addColumn('configvalue', 'text', [ |
|
| 62 | - 'notnull' => false, |
|
| 63 | - ]); |
|
| 64 | - $table->setPrimaryKey(['appid', 'configkey']); |
|
| 65 | - $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
| 66 | - $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if (!$schema->hasTable('storages')) { |
|
| 70 | - $table = $schema->createTable('storages'); |
|
| 71 | - $table->addColumn('id', 'string', [ |
|
| 72 | - 'notnull' => false, |
|
| 73 | - 'length' => 64, |
|
| 74 | - ]); |
|
| 75 | - $table->addColumn('numeric_id', Type::BIGINT, [ |
|
| 76 | - 'autoincrement' => true, |
|
| 77 | - 'notnull' => true, |
|
| 78 | - 'length' => 20, |
|
| 79 | - ]); |
|
| 80 | - $table->addColumn('available', 'integer', [ |
|
| 81 | - 'notnull' => true, |
|
| 82 | - 'default' => 1, |
|
| 83 | - ]); |
|
| 84 | - $table->addColumn('last_checked', 'integer', [ |
|
| 85 | - 'notnull' => false, |
|
| 86 | - ]); |
|
| 87 | - $table->setPrimaryKey(['numeric_id']); |
|
| 88 | - $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - if (!$schema->hasTable('mounts')) { |
|
| 92 | - $table = $schema->createTable('mounts'); |
|
| 93 | - $table->addColumn('id', 'integer', [ |
|
| 94 | - 'autoincrement' => true, |
|
| 95 | - 'notnull' => true, |
|
| 96 | - 'length' => 4, |
|
| 97 | - ]); |
|
| 98 | - $table->addColumn('storage_id', Type::BIGINT, [ |
|
| 99 | - 'notnull' => true, |
|
| 100 | - 'length' => 20, |
|
| 101 | - ]); |
|
| 102 | - $table->addColumn('root_id', Type::BIGINT, [ |
|
| 103 | - 'notnull' => true, |
|
| 104 | - 'length' => 20, |
|
| 105 | - ]); |
|
| 106 | - $table->addColumn('user_id', 'string', [ |
|
| 107 | - 'notnull' => true, |
|
| 108 | - 'length' => 64, |
|
| 109 | - ]); |
|
| 110 | - $table->addColumn('mount_point', 'string', [ |
|
| 111 | - 'notnull' => true, |
|
| 112 | - 'length' => 4000, |
|
| 113 | - ]); |
|
| 114 | - $table->addColumn('mount_id', Type::BIGINT, [ |
|
| 115 | - 'notnull' => false, |
|
| 116 | - 'length' => 20, |
|
| 117 | - ]); |
|
| 118 | - $table->setPrimaryKey(['id']); |
|
| 119 | - $table->addIndex(['user_id'], 'mounts_user_index'); |
|
| 120 | - $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
| 121 | - $table->addIndex(['root_id'], 'mounts_root_index'); |
|
| 122 | - $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 123 | - $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - if (!$schema->hasTable('mimetypes')) { |
|
| 127 | - $table = $schema->createTable('mimetypes'); |
|
| 128 | - $table->addColumn('id', Type::BIGINT, [ |
|
| 129 | - 'autoincrement' => true, |
|
| 130 | - 'notnull' => true, |
|
| 131 | - 'length' => 20, |
|
| 132 | - ]); |
|
| 133 | - $table->addColumn('mimetype', 'string', [ |
|
| 134 | - 'notnull' => true, |
|
| 135 | - 'length' => 255, |
|
| 136 | - 'default' => '', |
|
| 137 | - ]); |
|
| 138 | - $table->setPrimaryKey(['id']); |
|
| 139 | - $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if (!$schema->hasTable('filecache')) { |
|
| 143 | - $table = $schema->createTable('filecache'); |
|
| 144 | - $table->addColumn('fileid', Type::BIGINT, [ |
|
| 145 | - 'autoincrement' => true, |
|
| 146 | - 'notnull' => true, |
|
| 147 | - 'length' => 20, |
|
| 148 | - ]); |
|
| 149 | - $table->addColumn('storage', Type::BIGINT, [ |
|
| 150 | - 'notnull' => true, |
|
| 151 | - 'length' => 20, |
|
| 152 | - 'default' => 0, |
|
| 153 | - ]); |
|
| 154 | - $table->addColumn('path', 'string', [ |
|
| 155 | - 'notnull' => false, |
|
| 156 | - 'length' => 4000, |
|
| 157 | - ]); |
|
| 158 | - $table->addColumn('path_hash', 'string', [ |
|
| 159 | - 'notnull' => true, |
|
| 160 | - 'length' => 32, |
|
| 161 | - 'default' => '', |
|
| 162 | - ]); |
|
| 163 | - $table->addColumn('parent', Type::BIGINT, [ |
|
| 164 | - 'notnull' => true, |
|
| 165 | - 'length' => 20, |
|
| 166 | - 'default' => 0, |
|
| 167 | - ]); |
|
| 168 | - $table->addColumn('name', 'string', [ |
|
| 169 | - 'notnull' => false, |
|
| 170 | - 'length' => 250, |
|
| 171 | - ]); |
|
| 172 | - $table->addColumn('mimetype', Type::BIGINT, [ |
|
| 173 | - 'notnull' => true, |
|
| 174 | - 'length' => 20, |
|
| 175 | - 'default' => 0, |
|
| 176 | - ]); |
|
| 177 | - $table->addColumn('mimepart', Type::BIGINT, [ |
|
| 178 | - 'notnull' => true, |
|
| 179 | - 'length' => 20, |
|
| 180 | - 'default' => 0, |
|
| 181 | - ]); |
|
| 182 | - $table->addColumn('size', 'bigint', [ |
|
| 183 | - 'notnull' => true, |
|
| 184 | - 'length' => 8, |
|
| 185 | - 'default' => 0, |
|
| 186 | - ]); |
|
| 187 | - $table->addColumn('mtime', Type::BIGINT, [ |
|
| 188 | - 'notnull' => true, |
|
| 189 | - 'length' => 20, |
|
| 190 | - 'default' => 0, |
|
| 191 | - ]); |
|
| 192 | - $table->addColumn('storage_mtime', Type::BIGINT, [ |
|
| 193 | - 'notnull' => true, |
|
| 194 | - 'length' => 20, |
|
| 195 | - 'default' => 0, |
|
| 196 | - ]); |
|
| 197 | - $table->addColumn('encrypted', 'integer', [ |
|
| 198 | - 'notnull' => true, |
|
| 199 | - 'length' => 4, |
|
| 200 | - 'default' => 0, |
|
| 201 | - ]); |
|
| 202 | - $table->addColumn('unencrypted_size', 'bigint', [ |
|
| 203 | - 'notnull' => true, |
|
| 204 | - 'length' => 8, |
|
| 205 | - 'default' => 0, |
|
| 206 | - ]); |
|
| 207 | - $table->addColumn('etag', 'string', [ |
|
| 208 | - 'notnull' => false, |
|
| 209 | - 'length' => 40, |
|
| 210 | - ]); |
|
| 211 | - $table->addColumn('permissions', 'integer', [ |
|
| 212 | - 'notnull' => false, |
|
| 213 | - 'length' => 4, |
|
| 214 | - 'default' => 0, |
|
| 215 | - ]); |
|
| 216 | - $table->addColumn('checksum', 'string', [ |
|
| 217 | - 'notnull' => false, |
|
| 218 | - 'length' => 255, |
|
| 219 | - ]); |
|
| 220 | - $table->setPrimaryKey(['fileid']); |
|
| 221 | - $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
| 222 | - $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
| 223 | - $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
| 224 | - $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
| 225 | - $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
| 226 | - $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if (!$schema->hasTable('group_user')) { |
|
| 230 | - $table = $schema->createTable('group_user'); |
|
| 231 | - $table->addColumn('gid', 'string', [ |
|
| 232 | - 'notnull' => true, |
|
| 233 | - 'length' => 64, |
|
| 234 | - 'default' => '', |
|
| 235 | - ]); |
|
| 236 | - $table->addColumn('uid', 'string', [ |
|
| 237 | - 'notnull' => true, |
|
| 238 | - 'length' => 64, |
|
| 239 | - 'default' => '', |
|
| 240 | - ]); |
|
| 241 | - $table->setPrimaryKey(['gid', 'uid']); |
|
| 242 | - $table->addIndex(['uid'], 'gu_uid_index'); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - if (!$schema->hasTable('group_admin')) { |
|
| 246 | - $table = $schema->createTable('group_admin'); |
|
| 247 | - $table->addColumn('gid', 'string', [ |
|
| 248 | - 'notnull' => true, |
|
| 249 | - 'length' => 64, |
|
| 250 | - 'default' => '', |
|
| 251 | - ]); |
|
| 252 | - $table->addColumn('uid', 'string', [ |
|
| 253 | - 'notnull' => true, |
|
| 254 | - 'length' => 64, |
|
| 255 | - 'default' => '', |
|
| 256 | - ]); |
|
| 257 | - $table->setPrimaryKey(['gid', 'uid']); |
|
| 258 | - $table->addIndex(['uid'], 'group_admin_uid'); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - if (!$schema->hasTable('groups')) { |
|
| 262 | - $table = $schema->createTable('groups'); |
|
| 263 | - $table->addColumn('gid', 'string', [ |
|
| 264 | - 'notnull' => true, |
|
| 265 | - 'length' => 64, |
|
| 266 | - 'default' => '', |
|
| 267 | - ]); |
|
| 268 | - $table->setPrimaryKey(['gid']); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if (!$schema->hasTable('preferences')) { |
|
| 272 | - $table = $schema->createTable('preferences'); |
|
| 273 | - $table->addColumn('userid', 'string', [ |
|
| 274 | - 'notnull' => true, |
|
| 275 | - 'length' => 64, |
|
| 276 | - 'default' => '', |
|
| 277 | - ]); |
|
| 278 | - $table->addColumn('appid', 'string', [ |
|
| 279 | - 'notnull' => true, |
|
| 280 | - 'length' => 32, |
|
| 281 | - 'default' => '', |
|
| 282 | - ]); |
|
| 283 | - $table->addColumn('configkey', 'string', [ |
|
| 284 | - 'notnull' => true, |
|
| 285 | - 'length' => 64, |
|
| 286 | - 'default' => '', |
|
| 287 | - ]); |
|
| 288 | - $table->addColumn('configvalue', 'text', [ |
|
| 289 | - 'notnull' => false, |
|
| 290 | - ]); |
|
| 291 | - $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if (!$schema->hasTable('properties')) { |
|
| 295 | - $table = $schema->createTable('properties'); |
|
| 296 | - $table->addColumn('id', 'integer', [ |
|
| 297 | - 'autoincrement' => true, |
|
| 298 | - 'notnull' => true, |
|
| 299 | - 'length' => 4, |
|
| 300 | - ]); |
|
| 301 | - $table->addColumn('userid', 'string', [ |
|
| 302 | - 'notnull' => true, |
|
| 303 | - 'length' => 64, |
|
| 304 | - 'default' => '', |
|
| 305 | - ]); |
|
| 306 | - $table->addColumn('propertypath', 'string', [ |
|
| 307 | - 'notnull' => true, |
|
| 308 | - 'length' => 255, |
|
| 309 | - 'default' => '', |
|
| 310 | - ]); |
|
| 311 | - $table->addColumn('propertyname', 'string', [ |
|
| 312 | - 'notnull' => true, |
|
| 313 | - 'length' => 255, |
|
| 314 | - 'default' => '', |
|
| 315 | - ]); |
|
| 316 | - $table->addColumn('propertyvalue', 'text', [ |
|
| 317 | - 'notnull' => true, |
|
| 318 | - ]); |
|
| 319 | - $table->setPrimaryKey(['id']); |
|
| 320 | - $table->addIndex(['userid'], 'property_index'); |
|
| 321 | - $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - if (!$schema->hasTable('share')) { |
|
| 325 | - $table = $schema->createTable('share'); |
|
| 326 | - $table->addColumn('id', 'integer', [ |
|
| 327 | - 'autoincrement' => true, |
|
| 328 | - 'notnull' => true, |
|
| 329 | - 'length' => 4, |
|
| 330 | - ]); |
|
| 331 | - $table->addColumn('share_type', 'smallint', [ |
|
| 332 | - 'notnull' => true, |
|
| 333 | - 'length' => 1, |
|
| 334 | - 'default' => 0, |
|
| 335 | - ]); |
|
| 336 | - $table->addColumn('share_with', 'string', [ |
|
| 337 | - 'notnull' => false, |
|
| 338 | - 'length' => 255, |
|
| 339 | - ]); |
|
| 340 | - $table->addColumn('password', 'string', [ |
|
| 341 | - 'notnull' => false, |
|
| 342 | - 'length' => 255, |
|
| 343 | - ]); |
|
| 344 | - $table->addColumn('uid_owner', 'string', [ |
|
| 345 | - 'notnull' => true, |
|
| 346 | - 'length' => 64, |
|
| 347 | - 'default' => '', |
|
| 348 | - ]); |
|
| 349 | - $table->addColumn('uid_initiator', 'string', [ |
|
| 350 | - 'notnull' => false, |
|
| 351 | - 'length' => 64, |
|
| 352 | - ]); |
|
| 353 | - $table->addColumn('parent', 'integer', [ |
|
| 354 | - 'notnull' => false, |
|
| 355 | - 'length' => 4, |
|
| 356 | - ]); |
|
| 357 | - $table->addColumn('item_type', 'string', [ |
|
| 358 | - 'notnull' => true, |
|
| 359 | - 'length' => 64, |
|
| 360 | - 'default' => '', |
|
| 361 | - ]); |
|
| 362 | - $table->addColumn('item_source', 'string', [ |
|
| 363 | - 'notnull' => false, |
|
| 364 | - 'length' => 255, |
|
| 365 | - ]); |
|
| 366 | - $table->addColumn('item_target', 'string', [ |
|
| 367 | - 'notnull' => false, |
|
| 368 | - 'length' => 255, |
|
| 369 | - ]); |
|
| 370 | - $table->addColumn('file_source', 'integer', [ |
|
| 371 | - 'notnull' => false, |
|
| 372 | - 'length' => 4, |
|
| 373 | - ]); |
|
| 374 | - $table->addColumn('file_target', 'string', [ |
|
| 375 | - 'notnull' => false, |
|
| 376 | - 'length' => 512, |
|
| 377 | - ]); |
|
| 378 | - $table->addColumn('permissions', 'smallint', [ |
|
| 379 | - 'notnull' => true, |
|
| 380 | - 'length' => 1, |
|
| 381 | - 'default' => 0, |
|
| 382 | - ]); |
|
| 383 | - $table->addColumn('stime', 'bigint', [ |
|
| 384 | - 'notnull' => true, |
|
| 385 | - 'length' => 8, |
|
| 386 | - 'default' => 0, |
|
| 387 | - ]); |
|
| 388 | - $table->addColumn('accepted', 'smallint', [ |
|
| 389 | - 'notnull' => true, |
|
| 390 | - 'length' => 1, |
|
| 391 | - 'default' => 0, |
|
| 392 | - ]); |
|
| 393 | - $table->addColumn('expiration', 'datetime', [ |
|
| 394 | - 'notnull' => false, |
|
| 395 | - ]); |
|
| 396 | - $table->addColumn('token', 'string', [ |
|
| 397 | - 'notnull' => false, |
|
| 398 | - 'length' => 32, |
|
| 399 | - ]); |
|
| 400 | - $table->addColumn('mail_send', 'smallint', [ |
|
| 401 | - 'notnull' => true, |
|
| 402 | - 'length' => 1, |
|
| 403 | - 'default' => 0, |
|
| 404 | - ]); |
|
| 405 | - $table->addColumn('share_name', 'string', [ |
|
| 406 | - 'notnull' => false, |
|
| 407 | - 'length' => 64, |
|
| 408 | - ]); |
|
| 409 | - $table->setPrimaryKey(['id']); |
|
| 410 | - $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
| 411 | - $table->addIndex(['file_source'], 'file_source_index'); |
|
| 412 | - $table->addIndex(['token'], 'token_index'); |
|
| 413 | - $table->addIndex(['share_with'], 'share_with_index'); |
|
| 414 | - $table->addIndex(['parent'], 'parent_index'); |
|
| 415 | - $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 416 | - $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - if (!$schema->hasTable('jobs')) { |
|
| 420 | - $table = $schema->createTable('jobs'); |
|
| 421 | - $table->addColumn('id', 'integer', [ |
|
| 422 | - 'autoincrement' => true, |
|
| 423 | - 'notnull' => true, |
|
| 424 | - 'length' => 4, |
|
| 425 | - 'unsigned' => true, |
|
| 426 | - ]); |
|
| 427 | - $table->addColumn('class', 'string', [ |
|
| 428 | - 'notnull' => true, |
|
| 429 | - 'length' => 255, |
|
| 430 | - 'default' => '', |
|
| 431 | - ]); |
|
| 432 | - $table->addColumn('argument', 'string', [ |
|
| 433 | - 'notnull' => true, |
|
| 434 | - 'length' => 4000, |
|
| 435 | - 'default' => '', |
|
| 436 | - ]); |
|
| 437 | - $table->addColumn('last_run', 'integer', [ |
|
| 438 | - 'notnull' => false, |
|
| 439 | - 'default' => 0, |
|
| 440 | - ]); |
|
| 441 | - $table->addColumn('last_checked', 'integer', [ |
|
| 442 | - 'notnull' => false, |
|
| 443 | - 'default' => 0, |
|
| 444 | - ]); |
|
| 445 | - $table->addColumn('reserved_at', 'integer', [ |
|
| 446 | - 'notnull' => false, |
|
| 447 | - 'default' => 0, |
|
| 448 | - ]); |
|
| 449 | - $table->addColumn('execution_duration', 'integer', [ |
|
| 450 | - 'notnull' => true, |
|
| 451 | - 'default' => 0, |
|
| 452 | - ]); |
|
| 453 | - $table->setPrimaryKey(['id']); |
|
| 454 | - $table->addIndex(['class'], 'job_class_index'); |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - if (!$schema->hasTable('users')) { |
|
| 458 | - $table = $schema->createTable('users'); |
|
| 459 | - $table->addColumn('uid', 'string', [ |
|
| 460 | - 'notnull' => true, |
|
| 461 | - 'length' => 64, |
|
| 462 | - 'default' => '', |
|
| 463 | - ]); |
|
| 464 | - $table->addColumn('displayname', 'string', [ |
|
| 465 | - 'notnull' => false, |
|
| 466 | - 'length' => 64, |
|
| 467 | - ]); |
|
| 468 | - $table->addColumn('password', 'string', [ |
|
| 469 | - 'notnull' => true, |
|
| 470 | - 'length' => 255, |
|
| 471 | - 'default' => '', |
|
| 472 | - ]); |
|
| 473 | - $table->setPrimaryKey(['uid']); |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - if (!$schema->hasTable('authtoken')) { |
|
| 477 | - $table = $schema->createTable('authtoken'); |
|
| 478 | - $table->addColumn('id', 'integer', [ |
|
| 479 | - 'autoincrement' => true, |
|
| 480 | - 'notnull' => true, |
|
| 481 | - 'length' => 4, |
|
| 482 | - 'unsigned' => true, |
|
| 483 | - ]); |
|
| 484 | - $table->addColumn('uid', 'string', [ |
|
| 485 | - 'notnull' => true, |
|
| 486 | - 'length' => 64, |
|
| 487 | - 'default' => '', |
|
| 488 | - ]); |
|
| 489 | - $table->addColumn('login_name', 'string', [ |
|
| 490 | - 'notnull' => true, |
|
| 491 | - 'length' => 64, |
|
| 492 | - 'default' => '', |
|
| 493 | - ]); |
|
| 494 | - $table->addColumn('password', 'text', [ |
|
| 495 | - 'notnull' => false, |
|
| 496 | - ]); |
|
| 497 | - $table->addColumn('name', 'text', [ |
|
| 498 | - 'notnull' => true, |
|
| 499 | - 'default' => '', |
|
| 500 | - ]); |
|
| 501 | - $table->addColumn('token', 'string', [ |
|
| 502 | - 'notnull' => true, |
|
| 503 | - 'length' => 200, |
|
| 504 | - 'default' => '', |
|
| 505 | - ]); |
|
| 506 | - $table->addColumn('type', 'smallint', [ |
|
| 507 | - 'notnull' => true, |
|
| 508 | - 'length' => 2, |
|
| 509 | - 'default' => 0, |
|
| 510 | - 'unsigned' => true, |
|
| 511 | - ]); |
|
| 512 | - $table->addColumn('remember', 'smallint', [ |
|
| 513 | - 'notnull' => true, |
|
| 514 | - 'length' => 1, |
|
| 515 | - 'default' => 0, |
|
| 516 | - 'unsigned' => true, |
|
| 517 | - ]); |
|
| 518 | - $table->addColumn('last_activity', 'integer', [ |
|
| 519 | - 'notnull' => true, |
|
| 520 | - 'length' => 4, |
|
| 521 | - 'default' => 0, |
|
| 522 | - 'unsigned' => true, |
|
| 523 | - ]); |
|
| 524 | - $table->addColumn('last_check', 'integer', [ |
|
| 525 | - 'notnull' => true, |
|
| 526 | - 'length' => 4, |
|
| 527 | - 'default' => 0, |
|
| 528 | - 'unsigned' => true, |
|
| 529 | - ]); |
|
| 530 | - $table->addColumn('scope', 'text', [ |
|
| 531 | - 'notnull' => false, |
|
| 532 | - ]); |
|
| 533 | - $table->setPrimaryKey(['id']); |
|
| 534 | - $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
| 535 | - $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - if (!$schema->hasTable('bruteforce_attempts')) { |
|
| 539 | - $table = $schema->createTable('bruteforce_attempts'); |
|
| 540 | - $table->addColumn('id', 'integer', [ |
|
| 541 | - 'autoincrement' => true, |
|
| 542 | - 'notnull' => true, |
|
| 543 | - 'length' => 4, |
|
| 544 | - 'unsigned' => true, |
|
| 545 | - ]); |
|
| 546 | - $table->addColumn('action', 'string', [ |
|
| 547 | - 'notnull' => true, |
|
| 548 | - 'length' => 64, |
|
| 549 | - 'default' => '', |
|
| 550 | - ]); |
|
| 551 | - $table->addColumn('occurred', 'integer', [ |
|
| 552 | - 'notnull' => true, |
|
| 553 | - 'length' => 4, |
|
| 554 | - 'default' => 0, |
|
| 555 | - 'unsigned' => true, |
|
| 556 | - ]); |
|
| 557 | - $table->addColumn('ip', 'string', [ |
|
| 558 | - 'notnull' => true, |
|
| 559 | - 'length' => 255, |
|
| 560 | - 'default' => '', |
|
| 561 | - ]); |
|
| 562 | - $table->addColumn('subnet', 'string', [ |
|
| 563 | - 'notnull' => true, |
|
| 564 | - 'length' => 255, |
|
| 565 | - 'default' => '', |
|
| 566 | - ]); |
|
| 567 | - $table->addColumn('metadata', 'string', [ |
|
| 568 | - 'notnull' => true, |
|
| 569 | - 'length' => 255, |
|
| 570 | - 'default' => '', |
|
| 571 | - ]); |
|
| 572 | - $table->setPrimaryKey(['id']); |
|
| 573 | - $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
| 574 | - $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - if (!$schema->hasTable('vcategory')) { |
|
| 578 | - $table = $schema->createTable('vcategory'); |
|
| 579 | - $table->addColumn('id', 'integer', [ |
|
| 580 | - 'autoincrement' => true, |
|
| 581 | - 'notnull' => true, |
|
| 582 | - 'length' => 4, |
|
| 583 | - 'unsigned' => true, |
|
| 584 | - ]); |
|
| 585 | - $table->addColumn('uid', 'string', [ |
|
| 586 | - 'notnull' => true, |
|
| 587 | - 'length' => 64, |
|
| 588 | - 'default' => '', |
|
| 589 | - ]); |
|
| 590 | - $table->addColumn('type', 'string', [ |
|
| 591 | - 'notnull' => true, |
|
| 592 | - 'length' => 64, |
|
| 593 | - 'default' => '', |
|
| 594 | - ]); |
|
| 595 | - $table->addColumn('category', 'string', [ |
|
| 596 | - 'notnull' => true, |
|
| 597 | - 'length' => 255, |
|
| 598 | - 'default' => '', |
|
| 599 | - ]); |
|
| 600 | - $table->setPrimaryKey(['id']); |
|
| 601 | - $table->addIndex(['uid'], 'uid_index'); |
|
| 602 | - $table->addIndex(['type'], 'type_index'); |
|
| 603 | - $table->addIndex(['category'], 'category_index'); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - if (!$schema->hasTable('vcategory_to_object')) { |
|
| 607 | - $table = $schema->createTable('vcategory_to_object'); |
|
| 608 | - $table->addColumn('objid', 'integer', [ |
|
| 609 | - 'notnull' => true, |
|
| 610 | - 'length' => 4, |
|
| 611 | - 'default' => 0, |
|
| 612 | - 'unsigned' => true, |
|
| 613 | - ]); |
|
| 614 | - $table->addColumn('categoryid', 'integer', [ |
|
| 615 | - 'notnull' => true, |
|
| 616 | - 'length' => 4, |
|
| 617 | - 'default' => 0, |
|
| 618 | - 'unsigned' => true, |
|
| 619 | - ]); |
|
| 620 | - $table->addColumn('type', 'string', [ |
|
| 621 | - 'notnull' => true, |
|
| 622 | - 'length' => 64, |
|
| 623 | - 'default' => '', |
|
| 624 | - ]); |
|
| 625 | - $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
| 626 | - $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - if (!$schema->hasTable('systemtag')) { |
|
| 630 | - $table = $schema->createTable('systemtag'); |
|
| 631 | - $table->addColumn('id', 'integer', [ |
|
| 632 | - 'autoincrement' => true, |
|
| 633 | - 'notnull' => true, |
|
| 634 | - 'length' => 4, |
|
| 635 | - 'unsigned' => true, |
|
| 636 | - ]); |
|
| 637 | - $table->addColumn('name', 'string', [ |
|
| 638 | - 'notnull' => true, |
|
| 639 | - 'length' => 64, |
|
| 640 | - 'default' => '', |
|
| 641 | - ]); |
|
| 642 | - $table->addColumn('visibility', 'smallint', [ |
|
| 643 | - 'notnull' => true, |
|
| 644 | - 'length' => 1, |
|
| 645 | - 'default' => 1, |
|
| 646 | - ]); |
|
| 647 | - $table->addColumn('editable', 'smallint', [ |
|
| 648 | - 'notnull' => true, |
|
| 649 | - 'length' => 1, |
|
| 650 | - 'default' => 1, |
|
| 651 | - ]); |
|
| 652 | - $table->setPrimaryKey(['id']); |
|
| 653 | - $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - if (!$schema->hasTable('systemtag_object_mapping')) { |
|
| 657 | - $table = $schema->createTable('systemtag_object_mapping'); |
|
| 658 | - $table->addColumn('objectid', 'string', [ |
|
| 659 | - 'notnull' => true, |
|
| 660 | - 'length' => 64, |
|
| 661 | - 'default' => '', |
|
| 662 | - ]); |
|
| 663 | - $table->addColumn('objecttype', 'string', [ |
|
| 664 | - 'notnull' => true, |
|
| 665 | - 'length' => 64, |
|
| 666 | - 'default' => '', |
|
| 667 | - ]); |
|
| 668 | - $table->addColumn('systemtagid', 'integer', [ |
|
| 669 | - 'notnull' => true, |
|
| 670 | - 'length' => 4, |
|
| 671 | - 'default' => 0, |
|
| 672 | - 'unsigned' => true, |
|
| 673 | - ]); |
|
| 674 | - $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - if (!$schema->hasTable('systemtag_group')) { |
|
| 678 | - $table = $schema->createTable('systemtag_group'); |
|
| 679 | - $table->addColumn('systemtagid', 'integer', [ |
|
| 680 | - 'notnull' => true, |
|
| 681 | - 'length' => 4, |
|
| 682 | - 'default' => 0, |
|
| 683 | - 'unsigned' => true, |
|
| 684 | - ]); |
|
| 685 | - $table->addColumn('gid', 'string', [ |
|
| 686 | - 'notnull' => true, |
|
| 687 | - ]); |
|
| 688 | - $table->setPrimaryKey(['gid', 'systemtagid']); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - if (!$schema->hasTable('file_locks')) { |
|
| 692 | - $table = $schema->createTable('file_locks'); |
|
| 693 | - $table->addColumn('id', 'integer', [ |
|
| 694 | - 'autoincrement' => true, |
|
| 695 | - 'notnull' => true, |
|
| 696 | - 'length' => 4, |
|
| 697 | - 'unsigned' => true, |
|
| 698 | - ]); |
|
| 699 | - $table->addColumn('lock', 'integer', [ |
|
| 700 | - 'notnull' => true, |
|
| 701 | - 'length' => 4, |
|
| 702 | - 'default' => 0, |
|
| 703 | - ]); |
|
| 704 | - $table->addColumn('key', 'string', [ |
|
| 705 | - 'notnull' => true, |
|
| 706 | - 'length' => 64, |
|
| 707 | - ]); |
|
| 708 | - $table->addColumn('ttl', 'integer', [ |
|
| 709 | - 'notnull' => true, |
|
| 710 | - 'length' => 4, |
|
| 711 | - 'default' => -1, |
|
| 712 | - ]); |
|
| 713 | - $table->setPrimaryKey(['id']); |
|
| 714 | - $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
| 715 | - $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - if (!$schema->hasTable('comments')) { |
|
| 719 | - $table = $schema->createTable('comments'); |
|
| 720 | - $table->addColumn('id', 'integer', [ |
|
| 721 | - 'autoincrement' => true, |
|
| 722 | - 'notnull' => true, |
|
| 723 | - 'length' => 4, |
|
| 724 | - 'unsigned' => true, |
|
| 725 | - ]); |
|
| 726 | - $table->addColumn('parent_id', 'integer', [ |
|
| 727 | - 'notnull' => true, |
|
| 728 | - 'length' => 4, |
|
| 729 | - 'default' => 0, |
|
| 730 | - 'unsigned' => true, |
|
| 731 | - ]); |
|
| 732 | - $table->addColumn('topmost_parent_id', 'integer', [ |
|
| 733 | - 'notnull' => true, |
|
| 734 | - 'length' => 4, |
|
| 735 | - 'default' => 0, |
|
| 736 | - 'unsigned' => true, |
|
| 737 | - ]); |
|
| 738 | - $table->addColumn('children_count', 'integer', [ |
|
| 739 | - 'notnull' => true, |
|
| 740 | - 'length' => 4, |
|
| 741 | - 'default' => 0, |
|
| 742 | - 'unsigned' => true, |
|
| 743 | - ]); |
|
| 744 | - $table->addColumn('actor_type', 'string', [ |
|
| 745 | - 'notnull' => true, |
|
| 746 | - 'length' => 64, |
|
| 747 | - 'default' => '', |
|
| 748 | - ]); |
|
| 749 | - $table->addColumn('actor_id', 'string', [ |
|
| 750 | - 'notnull' => true, |
|
| 751 | - 'length' => 64, |
|
| 752 | - 'default' => '', |
|
| 753 | - ]); |
|
| 754 | - $table->addColumn('message', 'text', [ |
|
| 755 | - 'notnull' => false, |
|
| 756 | - ]); |
|
| 757 | - $table->addColumn('verb', 'string', [ |
|
| 758 | - 'notnull' => false, |
|
| 759 | - 'length' => 64, |
|
| 760 | - ]); |
|
| 761 | - $table->addColumn('creation_timestamp', 'datetime', [ |
|
| 762 | - 'notnull' => false, |
|
| 763 | - ]); |
|
| 764 | - $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
| 765 | - 'notnull' => false, |
|
| 766 | - ]); |
|
| 767 | - $table->addColumn('object_type', 'string', [ |
|
| 768 | - 'notnull' => true, |
|
| 769 | - 'length' => 64, |
|
| 770 | - 'default' => '', |
|
| 771 | - ]); |
|
| 772 | - $table->addColumn('object_id', 'string', [ |
|
| 773 | - 'notnull' => true, |
|
| 774 | - 'length' => 64, |
|
| 775 | - 'default' => '', |
|
| 776 | - ]); |
|
| 777 | - $table->addColumn('reference_id', 'string', [ |
|
| 778 | - 'notnull' => false, |
|
| 779 | - 'length' => 64, |
|
| 780 | - ]); |
|
| 781 | - $table->setPrimaryKey(['id']); |
|
| 782 | - $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
| 783 | - $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
| 784 | - $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
| 785 | - $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
| 786 | - } |
|
| 787 | - |
|
| 788 | - if (!$schema->hasTable('comments_read_markers')) { |
|
| 789 | - $table = $schema->createTable('comments_read_markers'); |
|
| 790 | - $table->addColumn('user_id', 'string', [ |
|
| 791 | - 'notnull' => true, |
|
| 792 | - 'length' => 64, |
|
| 793 | - 'default' => '', |
|
| 794 | - ]); |
|
| 795 | - $table->addColumn('marker_datetime', 'datetime', [ |
|
| 796 | - 'notnull' => false, |
|
| 797 | - ]); |
|
| 798 | - $table->addColumn('object_type', 'string', [ |
|
| 799 | - 'notnull' => true, |
|
| 800 | - 'length' => 64, |
|
| 801 | - 'default' => '', |
|
| 802 | - ]); |
|
| 803 | - $table->addColumn('object_id', 'string', [ |
|
| 804 | - 'notnull' => true, |
|
| 805 | - 'length' => 64, |
|
| 806 | - 'default' => '', |
|
| 807 | - ]); |
|
| 808 | - $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
| 809 | - $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
|
| 810 | - } |
|
| 811 | - |
|
| 812 | - if (!$schema->hasTable('credentials')) { |
|
| 813 | - $table = $schema->createTable('credentials'); |
|
| 814 | - $table->addColumn('user', 'string', [ |
|
| 815 | - 'notnull' => true, |
|
| 816 | - 'length' => 64, |
|
| 817 | - ]); |
|
| 818 | - $table->addColumn('identifier', 'string', [ |
|
| 819 | - 'notnull' => true, |
|
| 820 | - 'length' => 64, |
|
| 821 | - ]); |
|
| 822 | - $table->addColumn('credentials', 'text', [ |
|
| 823 | - 'notnull' => false, |
|
| 824 | - ]); |
|
| 825 | - $table->setPrimaryKey(['user', 'identifier']); |
|
| 826 | - $table->addIndex(['user'], 'credentials_user'); |
|
| 827 | - } |
|
| 828 | - |
|
| 829 | - if (!$schema->hasTable('admin_sections')) { |
|
| 830 | - $table = $schema->createTable('admin_sections'); |
|
| 831 | - $table->addColumn('id', 'string', [ |
|
| 832 | - 'notnull' => true, |
|
| 833 | - 'length' => 64, |
|
| 834 | - ]); |
|
| 835 | - $table->addColumn('class', 'string', [ |
|
| 836 | - 'notnull' => true, |
|
| 837 | - 'length' => 255, |
|
| 838 | - 'default' => '', |
|
| 839 | - ]); |
|
| 840 | - $table->addColumn('priority', 'smallint', [ |
|
| 841 | - 'notnull' => true, |
|
| 842 | - 'length' => 1, |
|
| 843 | - 'default' => 0, |
|
| 844 | - ]); |
|
| 845 | - $table->setPrimaryKey(['id']); |
|
| 846 | - $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
| 847 | - } |
|
| 848 | - |
|
| 849 | - if (!$schema->hasTable('admin_settings')) { |
|
| 850 | - $table = $schema->createTable('admin_settings'); |
|
| 851 | - $table->addColumn('id', 'integer', [ |
|
| 852 | - 'autoincrement' => true, |
|
| 853 | - 'notnull' => true, |
|
| 854 | - 'length' => 4, |
|
| 855 | - ]); |
|
| 856 | - $table->addColumn('class', 'string', [ |
|
| 857 | - 'notnull' => true, |
|
| 858 | - 'length' => 255, |
|
| 859 | - 'default' => '', |
|
| 860 | - ]); |
|
| 861 | - $table->addColumn('section', 'string', [ |
|
| 862 | - 'notnull' => false, |
|
| 863 | - 'length' => 64, |
|
| 864 | - ]); |
|
| 865 | - $table->addColumn('priority', 'smallint', [ |
|
| 866 | - 'notnull' => true, |
|
| 867 | - 'length' => 1, |
|
| 868 | - 'default' => 0, |
|
| 869 | - ]); |
|
| 870 | - $table->setPrimaryKey(['id']); |
|
| 871 | - $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
| 872 | - $table->addIndex(['section'], 'admin_settings_section'); |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - if (!$schema->hasTable('personal_sections')) { |
|
| 876 | - $table = $schema->createTable('personal_sections'); |
|
| 877 | - $table->addColumn('id', 'string', [ |
|
| 878 | - 'notnull' => true, |
|
| 879 | - 'length' => 64, |
|
| 880 | - ]); |
|
| 881 | - $table->addColumn('class', 'string', [ |
|
| 882 | - 'notnull' => true, |
|
| 883 | - 'length' => 255, |
|
| 884 | - 'default' => '', |
|
| 885 | - ]); |
|
| 886 | - $table->addColumn('priority', 'smallint', [ |
|
| 887 | - 'notnull' => true, |
|
| 888 | - 'length' => 1, |
|
| 889 | - 'default' => 0, |
|
| 890 | - ]); |
|
| 891 | - $table->setPrimaryKey(['id']); |
|
| 892 | - $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - if (!$schema->hasTable('personal_settings')) { |
|
| 896 | - $table = $schema->createTable('personal_settings'); |
|
| 897 | - $table->addColumn('id', 'integer', [ |
|
| 898 | - 'autoincrement' => true, |
|
| 899 | - 'notnull' => true, |
|
| 900 | - 'length' => 4, |
|
| 901 | - ]); |
|
| 902 | - $table->addColumn('class', 'string', [ |
|
| 903 | - 'notnull' => true, |
|
| 904 | - 'length' => 255, |
|
| 905 | - 'default' => '', |
|
| 906 | - ]); |
|
| 907 | - $table->addColumn('section', 'string', [ |
|
| 908 | - 'notnull' => false, |
|
| 909 | - 'length' => 64, |
|
| 910 | - ]); |
|
| 911 | - $table->addColumn('priority', 'smallint', [ |
|
| 912 | - 'notnull' => true, |
|
| 913 | - 'length' => 1, |
|
| 914 | - 'default' => 0, |
|
| 915 | - ]); |
|
| 916 | - $table->setPrimaryKey(['id']); |
|
| 917 | - $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
| 918 | - $table->addIndex(['section'], 'personal_settings_section'); |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - if (!$schema->hasTable('accounts')) { |
|
| 922 | - $table = $schema->createTable('accounts'); |
|
| 923 | - $table->addColumn('uid', 'string', [ |
|
| 924 | - 'notnull' => true, |
|
| 925 | - 'length' => 64, |
|
| 926 | - 'default' => '', |
|
| 927 | - ]); |
|
| 928 | - $table->addColumn('data', 'text', [ |
|
| 929 | - 'notnull' => true, |
|
| 930 | - 'default' => '', |
|
| 931 | - ]); |
|
| 932 | - $table->setPrimaryKey(['uid']); |
|
| 933 | - } |
|
| 934 | - return $schema; |
|
| 935 | - } |
|
| 38 | + /** |
|
| 39 | + * @param IOutput $output |
|
| 40 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 41 | + * @param array $options |
|
| 42 | + * @return null|ISchemaWrapper |
|
| 43 | + * @since 13.0.0 |
|
| 44 | + */ |
|
| 45 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 46 | + /** @var ISchemaWrapper $schema */ |
|
| 47 | + $schema = $schemaClosure(); |
|
| 48 | + |
|
| 49 | + if (!$schema->hasTable('appconfig')) { |
|
| 50 | + $table = $schema->createTable('appconfig'); |
|
| 51 | + $table->addColumn('appid', 'string', [ |
|
| 52 | + 'notnull' => true, |
|
| 53 | + 'length' => 32, |
|
| 54 | + 'default' => '', |
|
| 55 | + ]); |
|
| 56 | + $table->addColumn('configkey', 'string', [ |
|
| 57 | + 'notnull' => true, |
|
| 58 | + 'length' => 64, |
|
| 59 | + 'default' => '', |
|
| 60 | + ]); |
|
| 61 | + $table->addColumn('configvalue', 'text', [ |
|
| 62 | + 'notnull' => false, |
|
| 63 | + ]); |
|
| 64 | + $table->setPrimaryKey(['appid', 'configkey']); |
|
| 65 | + $table->addIndex(['configkey'], 'appconfig_config_key_index'); |
|
| 66 | + $table->addIndex(['appid'], 'appconfig_appid_key'); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if (!$schema->hasTable('storages')) { |
|
| 70 | + $table = $schema->createTable('storages'); |
|
| 71 | + $table->addColumn('id', 'string', [ |
|
| 72 | + 'notnull' => false, |
|
| 73 | + 'length' => 64, |
|
| 74 | + ]); |
|
| 75 | + $table->addColumn('numeric_id', Type::BIGINT, [ |
|
| 76 | + 'autoincrement' => true, |
|
| 77 | + 'notnull' => true, |
|
| 78 | + 'length' => 20, |
|
| 79 | + ]); |
|
| 80 | + $table->addColumn('available', 'integer', [ |
|
| 81 | + 'notnull' => true, |
|
| 82 | + 'default' => 1, |
|
| 83 | + ]); |
|
| 84 | + $table->addColumn('last_checked', 'integer', [ |
|
| 85 | + 'notnull' => false, |
|
| 86 | + ]); |
|
| 87 | + $table->setPrimaryKey(['numeric_id']); |
|
| 88 | + $table->addUniqueIndex(['id'], 'storages_id_index'); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + if (!$schema->hasTable('mounts')) { |
|
| 92 | + $table = $schema->createTable('mounts'); |
|
| 93 | + $table->addColumn('id', 'integer', [ |
|
| 94 | + 'autoincrement' => true, |
|
| 95 | + 'notnull' => true, |
|
| 96 | + 'length' => 4, |
|
| 97 | + ]); |
|
| 98 | + $table->addColumn('storage_id', Type::BIGINT, [ |
|
| 99 | + 'notnull' => true, |
|
| 100 | + 'length' => 20, |
|
| 101 | + ]); |
|
| 102 | + $table->addColumn('root_id', Type::BIGINT, [ |
|
| 103 | + 'notnull' => true, |
|
| 104 | + 'length' => 20, |
|
| 105 | + ]); |
|
| 106 | + $table->addColumn('user_id', 'string', [ |
|
| 107 | + 'notnull' => true, |
|
| 108 | + 'length' => 64, |
|
| 109 | + ]); |
|
| 110 | + $table->addColumn('mount_point', 'string', [ |
|
| 111 | + 'notnull' => true, |
|
| 112 | + 'length' => 4000, |
|
| 113 | + ]); |
|
| 114 | + $table->addColumn('mount_id', Type::BIGINT, [ |
|
| 115 | + 'notnull' => false, |
|
| 116 | + 'length' => 20, |
|
| 117 | + ]); |
|
| 118 | + $table->setPrimaryKey(['id']); |
|
| 119 | + $table->addIndex(['user_id'], 'mounts_user_index'); |
|
| 120 | + $table->addIndex(['storage_id'], 'mounts_storage_index'); |
|
| 121 | + $table->addIndex(['root_id'], 'mounts_root_index'); |
|
| 122 | + $table->addIndex(['mount_id'], 'mounts_mount_id_index'); |
|
| 123 | + $table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index'); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + if (!$schema->hasTable('mimetypes')) { |
|
| 127 | + $table = $schema->createTable('mimetypes'); |
|
| 128 | + $table->addColumn('id', Type::BIGINT, [ |
|
| 129 | + 'autoincrement' => true, |
|
| 130 | + 'notnull' => true, |
|
| 131 | + 'length' => 20, |
|
| 132 | + ]); |
|
| 133 | + $table->addColumn('mimetype', 'string', [ |
|
| 134 | + 'notnull' => true, |
|
| 135 | + 'length' => 255, |
|
| 136 | + 'default' => '', |
|
| 137 | + ]); |
|
| 138 | + $table->setPrimaryKey(['id']); |
|
| 139 | + $table->addUniqueIndex(['mimetype'], 'mimetype_id_index'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if (!$schema->hasTable('filecache')) { |
|
| 143 | + $table = $schema->createTable('filecache'); |
|
| 144 | + $table->addColumn('fileid', Type::BIGINT, [ |
|
| 145 | + 'autoincrement' => true, |
|
| 146 | + 'notnull' => true, |
|
| 147 | + 'length' => 20, |
|
| 148 | + ]); |
|
| 149 | + $table->addColumn('storage', Type::BIGINT, [ |
|
| 150 | + 'notnull' => true, |
|
| 151 | + 'length' => 20, |
|
| 152 | + 'default' => 0, |
|
| 153 | + ]); |
|
| 154 | + $table->addColumn('path', 'string', [ |
|
| 155 | + 'notnull' => false, |
|
| 156 | + 'length' => 4000, |
|
| 157 | + ]); |
|
| 158 | + $table->addColumn('path_hash', 'string', [ |
|
| 159 | + 'notnull' => true, |
|
| 160 | + 'length' => 32, |
|
| 161 | + 'default' => '', |
|
| 162 | + ]); |
|
| 163 | + $table->addColumn('parent', Type::BIGINT, [ |
|
| 164 | + 'notnull' => true, |
|
| 165 | + 'length' => 20, |
|
| 166 | + 'default' => 0, |
|
| 167 | + ]); |
|
| 168 | + $table->addColumn('name', 'string', [ |
|
| 169 | + 'notnull' => false, |
|
| 170 | + 'length' => 250, |
|
| 171 | + ]); |
|
| 172 | + $table->addColumn('mimetype', Type::BIGINT, [ |
|
| 173 | + 'notnull' => true, |
|
| 174 | + 'length' => 20, |
|
| 175 | + 'default' => 0, |
|
| 176 | + ]); |
|
| 177 | + $table->addColumn('mimepart', Type::BIGINT, [ |
|
| 178 | + 'notnull' => true, |
|
| 179 | + 'length' => 20, |
|
| 180 | + 'default' => 0, |
|
| 181 | + ]); |
|
| 182 | + $table->addColumn('size', 'bigint', [ |
|
| 183 | + 'notnull' => true, |
|
| 184 | + 'length' => 8, |
|
| 185 | + 'default' => 0, |
|
| 186 | + ]); |
|
| 187 | + $table->addColumn('mtime', Type::BIGINT, [ |
|
| 188 | + 'notnull' => true, |
|
| 189 | + 'length' => 20, |
|
| 190 | + 'default' => 0, |
|
| 191 | + ]); |
|
| 192 | + $table->addColumn('storage_mtime', Type::BIGINT, [ |
|
| 193 | + 'notnull' => true, |
|
| 194 | + 'length' => 20, |
|
| 195 | + 'default' => 0, |
|
| 196 | + ]); |
|
| 197 | + $table->addColumn('encrypted', 'integer', [ |
|
| 198 | + 'notnull' => true, |
|
| 199 | + 'length' => 4, |
|
| 200 | + 'default' => 0, |
|
| 201 | + ]); |
|
| 202 | + $table->addColumn('unencrypted_size', 'bigint', [ |
|
| 203 | + 'notnull' => true, |
|
| 204 | + 'length' => 8, |
|
| 205 | + 'default' => 0, |
|
| 206 | + ]); |
|
| 207 | + $table->addColumn('etag', 'string', [ |
|
| 208 | + 'notnull' => false, |
|
| 209 | + 'length' => 40, |
|
| 210 | + ]); |
|
| 211 | + $table->addColumn('permissions', 'integer', [ |
|
| 212 | + 'notnull' => false, |
|
| 213 | + 'length' => 4, |
|
| 214 | + 'default' => 0, |
|
| 215 | + ]); |
|
| 216 | + $table->addColumn('checksum', 'string', [ |
|
| 217 | + 'notnull' => false, |
|
| 218 | + 'length' => 255, |
|
| 219 | + ]); |
|
| 220 | + $table->setPrimaryKey(['fileid']); |
|
| 221 | + $table->addUniqueIndex(['storage', 'path_hash'], 'fs_storage_path_hash'); |
|
| 222 | + $table->addIndex(['parent', 'name'], 'fs_parent_name_hash'); |
|
| 223 | + $table->addIndex(['storage', 'mimetype'], 'fs_storage_mimetype'); |
|
| 224 | + $table->addIndex(['storage', 'mimepart'], 'fs_storage_mimepart'); |
|
| 225 | + $table->addIndex(['storage', 'size', 'fileid'], 'fs_storage_size'); |
|
| 226 | + $table->addIndex(['mtime'], 'fs_mtime'); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if (!$schema->hasTable('group_user')) { |
|
| 230 | + $table = $schema->createTable('group_user'); |
|
| 231 | + $table->addColumn('gid', 'string', [ |
|
| 232 | + 'notnull' => true, |
|
| 233 | + 'length' => 64, |
|
| 234 | + 'default' => '', |
|
| 235 | + ]); |
|
| 236 | + $table->addColumn('uid', 'string', [ |
|
| 237 | + 'notnull' => true, |
|
| 238 | + 'length' => 64, |
|
| 239 | + 'default' => '', |
|
| 240 | + ]); |
|
| 241 | + $table->setPrimaryKey(['gid', 'uid']); |
|
| 242 | + $table->addIndex(['uid'], 'gu_uid_index'); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + if (!$schema->hasTable('group_admin')) { |
|
| 246 | + $table = $schema->createTable('group_admin'); |
|
| 247 | + $table->addColumn('gid', 'string', [ |
|
| 248 | + 'notnull' => true, |
|
| 249 | + 'length' => 64, |
|
| 250 | + 'default' => '', |
|
| 251 | + ]); |
|
| 252 | + $table->addColumn('uid', 'string', [ |
|
| 253 | + 'notnull' => true, |
|
| 254 | + 'length' => 64, |
|
| 255 | + 'default' => '', |
|
| 256 | + ]); |
|
| 257 | + $table->setPrimaryKey(['gid', 'uid']); |
|
| 258 | + $table->addIndex(['uid'], 'group_admin_uid'); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + if (!$schema->hasTable('groups')) { |
|
| 262 | + $table = $schema->createTable('groups'); |
|
| 263 | + $table->addColumn('gid', 'string', [ |
|
| 264 | + 'notnull' => true, |
|
| 265 | + 'length' => 64, |
|
| 266 | + 'default' => '', |
|
| 267 | + ]); |
|
| 268 | + $table->setPrimaryKey(['gid']); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if (!$schema->hasTable('preferences')) { |
|
| 272 | + $table = $schema->createTable('preferences'); |
|
| 273 | + $table->addColumn('userid', 'string', [ |
|
| 274 | + 'notnull' => true, |
|
| 275 | + 'length' => 64, |
|
| 276 | + 'default' => '', |
|
| 277 | + ]); |
|
| 278 | + $table->addColumn('appid', 'string', [ |
|
| 279 | + 'notnull' => true, |
|
| 280 | + 'length' => 32, |
|
| 281 | + 'default' => '', |
|
| 282 | + ]); |
|
| 283 | + $table->addColumn('configkey', 'string', [ |
|
| 284 | + 'notnull' => true, |
|
| 285 | + 'length' => 64, |
|
| 286 | + 'default' => '', |
|
| 287 | + ]); |
|
| 288 | + $table->addColumn('configvalue', 'text', [ |
|
| 289 | + 'notnull' => false, |
|
| 290 | + ]); |
|
| 291 | + $table->setPrimaryKey(['userid', 'appid', 'configkey']); |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if (!$schema->hasTable('properties')) { |
|
| 295 | + $table = $schema->createTable('properties'); |
|
| 296 | + $table->addColumn('id', 'integer', [ |
|
| 297 | + 'autoincrement' => true, |
|
| 298 | + 'notnull' => true, |
|
| 299 | + 'length' => 4, |
|
| 300 | + ]); |
|
| 301 | + $table->addColumn('userid', 'string', [ |
|
| 302 | + 'notnull' => true, |
|
| 303 | + 'length' => 64, |
|
| 304 | + 'default' => '', |
|
| 305 | + ]); |
|
| 306 | + $table->addColumn('propertypath', 'string', [ |
|
| 307 | + 'notnull' => true, |
|
| 308 | + 'length' => 255, |
|
| 309 | + 'default' => '', |
|
| 310 | + ]); |
|
| 311 | + $table->addColumn('propertyname', 'string', [ |
|
| 312 | + 'notnull' => true, |
|
| 313 | + 'length' => 255, |
|
| 314 | + 'default' => '', |
|
| 315 | + ]); |
|
| 316 | + $table->addColumn('propertyvalue', 'text', [ |
|
| 317 | + 'notnull' => true, |
|
| 318 | + ]); |
|
| 319 | + $table->setPrimaryKey(['id']); |
|
| 320 | + $table->addIndex(['userid'], 'property_index'); |
|
| 321 | + $table->addIndex(['userid', 'propertypath'], 'properties_path_index'); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + if (!$schema->hasTable('share')) { |
|
| 325 | + $table = $schema->createTable('share'); |
|
| 326 | + $table->addColumn('id', 'integer', [ |
|
| 327 | + 'autoincrement' => true, |
|
| 328 | + 'notnull' => true, |
|
| 329 | + 'length' => 4, |
|
| 330 | + ]); |
|
| 331 | + $table->addColumn('share_type', 'smallint', [ |
|
| 332 | + 'notnull' => true, |
|
| 333 | + 'length' => 1, |
|
| 334 | + 'default' => 0, |
|
| 335 | + ]); |
|
| 336 | + $table->addColumn('share_with', 'string', [ |
|
| 337 | + 'notnull' => false, |
|
| 338 | + 'length' => 255, |
|
| 339 | + ]); |
|
| 340 | + $table->addColumn('password', 'string', [ |
|
| 341 | + 'notnull' => false, |
|
| 342 | + 'length' => 255, |
|
| 343 | + ]); |
|
| 344 | + $table->addColumn('uid_owner', 'string', [ |
|
| 345 | + 'notnull' => true, |
|
| 346 | + 'length' => 64, |
|
| 347 | + 'default' => '', |
|
| 348 | + ]); |
|
| 349 | + $table->addColumn('uid_initiator', 'string', [ |
|
| 350 | + 'notnull' => false, |
|
| 351 | + 'length' => 64, |
|
| 352 | + ]); |
|
| 353 | + $table->addColumn('parent', 'integer', [ |
|
| 354 | + 'notnull' => false, |
|
| 355 | + 'length' => 4, |
|
| 356 | + ]); |
|
| 357 | + $table->addColumn('item_type', 'string', [ |
|
| 358 | + 'notnull' => true, |
|
| 359 | + 'length' => 64, |
|
| 360 | + 'default' => '', |
|
| 361 | + ]); |
|
| 362 | + $table->addColumn('item_source', 'string', [ |
|
| 363 | + 'notnull' => false, |
|
| 364 | + 'length' => 255, |
|
| 365 | + ]); |
|
| 366 | + $table->addColumn('item_target', 'string', [ |
|
| 367 | + 'notnull' => false, |
|
| 368 | + 'length' => 255, |
|
| 369 | + ]); |
|
| 370 | + $table->addColumn('file_source', 'integer', [ |
|
| 371 | + 'notnull' => false, |
|
| 372 | + 'length' => 4, |
|
| 373 | + ]); |
|
| 374 | + $table->addColumn('file_target', 'string', [ |
|
| 375 | + 'notnull' => false, |
|
| 376 | + 'length' => 512, |
|
| 377 | + ]); |
|
| 378 | + $table->addColumn('permissions', 'smallint', [ |
|
| 379 | + 'notnull' => true, |
|
| 380 | + 'length' => 1, |
|
| 381 | + 'default' => 0, |
|
| 382 | + ]); |
|
| 383 | + $table->addColumn('stime', 'bigint', [ |
|
| 384 | + 'notnull' => true, |
|
| 385 | + 'length' => 8, |
|
| 386 | + 'default' => 0, |
|
| 387 | + ]); |
|
| 388 | + $table->addColumn('accepted', 'smallint', [ |
|
| 389 | + 'notnull' => true, |
|
| 390 | + 'length' => 1, |
|
| 391 | + 'default' => 0, |
|
| 392 | + ]); |
|
| 393 | + $table->addColumn('expiration', 'datetime', [ |
|
| 394 | + 'notnull' => false, |
|
| 395 | + ]); |
|
| 396 | + $table->addColumn('token', 'string', [ |
|
| 397 | + 'notnull' => false, |
|
| 398 | + 'length' => 32, |
|
| 399 | + ]); |
|
| 400 | + $table->addColumn('mail_send', 'smallint', [ |
|
| 401 | + 'notnull' => true, |
|
| 402 | + 'length' => 1, |
|
| 403 | + 'default' => 0, |
|
| 404 | + ]); |
|
| 405 | + $table->addColumn('share_name', 'string', [ |
|
| 406 | + 'notnull' => false, |
|
| 407 | + 'length' => 64, |
|
| 408 | + ]); |
|
| 409 | + $table->setPrimaryKey(['id']); |
|
| 410 | + $table->addIndex(['item_type', 'share_type'], 'item_share_type_index'); |
|
| 411 | + $table->addIndex(['file_source'], 'file_source_index'); |
|
| 412 | + $table->addIndex(['token'], 'token_index'); |
|
| 413 | + $table->addIndex(['share_with'], 'share_with_index'); |
|
| 414 | + $table->addIndex(['parent'], 'parent_index'); |
|
| 415 | + $table->addIndex(['uid_owner'], 'owner_index'); |
|
| 416 | + $table->addIndex(['uid_initiator'], 'initiator_index'); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + if (!$schema->hasTable('jobs')) { |
|
| 420 | + $table = $schema->createTable('jobs'); |
|
| 421 | + $table->addColumn('id', 'integer', [ |
|
| 422 | + 'autoincrement' => true, |
|
| 423 | + 'notnull' => true, |
|
| 424 | + 'length' => 4, |
|
| 425 | + 'unsigned' => true, |
|
| 426 | + ]); |
|
| 427 | + $table->addColumn('class', 'string', [ |
|
| 428 | + 'notnull' => true, |
|
| 429 | + 'length' => 255, |
|
| 430 | + 'default' => '', |
|
| 431 | + ]); |
|
| 432 | + $table->addColumn('argument', 'string', [ |
|
| 433 | + 'notnull' => true, |
|
| 434 | + 'length' => 4000, |
|
| 435 | + 'default' => '', |
|
| 436 | + ]); |
|
| 437 | + $table->addColumn('last_run', 'integer', [ |
|
| 438 | + 'notnull' => false, |
|
| 439 | + 'default' => 0, |
|
| 440 | + ]); |
|
| 441 | + $table->addColumn('last_checked', 'integer', [ |
|
| 442 | + 'notnull' => false, |
|
| 443 | + 'default' => 0, |
|
| 444 | + ]); |
|
| 445 | + $table->addColumn('reserved_at', 'integer', [ |
|
| 446 | + 'notnull' => false, |
|
| 447 | + 'default' => 0, |
|
| 448 | + ]); |
|
| 449 | + $table->addColumn('execution_duration', 'integer', [ |
|
| 450 | + 'notnull' => true, |
|
| 451 | + 'default' => 0, |
|
| 452 | + ]); |
|
| 453 | + $table->setPrimaryKey(['id']); |
|
| 454 | + $table->addIndex(['class'], 'job_class_index'); |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + if (!$schema->hasTable('users')) { |
|
| 458 | + $table = $schema->createTable('users'); |
|
| 459 | + $table->addColumn('uid', 'string', [ |
|
| 460 | + 'notnull' => true, |
|
| 461 | + 'length' => 64, |
|
| 462 | + 'default' => '', |
|
| 463 | + ]); |
|
| 464 | + $table->addColumn('displayname', 'string', [ |
|
| 465 | + 'notnull' => false, |
|
| 466 | + 'length' => 64, |
|
| 467 | + ]); |
|
| 468 | + $table->addColumn('password', 'string', [ |
|
| 469 | + 'notnull' => true, |
|
| 470 | + 'length' => 255, |
|
| 471 | + 'default' => '', |
|
| 472 | + ]); |
|
| 473 | + $table->setPrimaryKey(['uid']); |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + if (!$schema->hasTable('authtoken')) { |
|
| 477 | + $table = $schema->createTable('authtoken'); |
|
| 478 | + $table->addColumn('id', 'integer', [ |
|
| 479 | + 'autoincrement' => true, |
|
| 480 | + 'notnull' => true, |
|
| 481 | + 'length' => 4, |
|
| 482 | + 'unsigned' => true, |
|
| 483 | + ]); |
|
| 484 | + $table->addColumn('uid', 'string', [ |
|
| 485 | + 'notnull' => true, |
|
| 486 | + 'length' => 64, |
|
| 487 | + 'default' => '', |
|
| 488 | + ]); |
|
| 489 | + $table->addColumn('login_name', 'string', [ |
|
| 490 | + 'notnull' => true, |
|
| 491 | + 'length' => 64, |
|
| 492 | + 'default' => '', |
|
| 493 | + ]); |
|
| 494 | + $table->addColumn('password', 'text', [ |
|
| 495 | + 'notnull' => false, |
|
| 496 | + ]); |
|
| 497 | + $table->addColumn('name', 'text', [ |
|
| 498 | + 'notnull' => true, |
|
| 499 | + 'default' => '', |
|
| 500 | + ]); |
|
| 501 | + $table->addColumn('token', 'string', [ |
|
| 502 | + 'notnull' => true, |
|
| 503 | + 'length' => 200, |
|
| 504 | + 'default' => '', |
|
| 505 | + ]); |
|
| 506 | + $table->addColumn('type', 'smallint', [ |
|
| 507 | + 'notnull' => true, |
|
| 508 | + 'length' => 2, |
|
| 509 | + 'default' => 0, |
|
| 510 | + 'unsigned' => true, |
|
| 511 | + ]); |
|
| 512 | + $table->addColumn('remember', 'smallint', [ |
|
| 513 | + 'notnull' => true, |
|
| 514 | + 'length' => 1, |
|
| 515 | + 'default' => 0, |
|
| 516 | + 'unsigned' => true, |
|
| 517 | + ]); |
|
| 518 | + $table->addColumn('last_activity', 'integer', [ |
|
| 519 | + 'notnull' => true, |
|
| 520 | + 'length' => 4, |
|
| 521 | + 'default' => 0, |
|
| 522 | + 'unsigned' => true, |
|
| 523 | + ]); |
|
| 524 | + $table->addColumn('last_check', 'integer', [ |
|
| 525 | + 'notnull' => true, |
|
| 526 | + 'length' => 4, |
|
| 527 | + 'default' => 0, |
|
| 528 | + 'unsigned' => true, |
|
| 529 | + ]); |
|
| 530 | + $table->addColumn('scope', 'text', [ |
|
| 531 | + 'notnull' => false, |
|
| 532 | + ]); |
|
| 533 | + $table->setPrimaryKey(['id']); |
|
| 534 | + $table->addUniqueIndex(['token'], 'authtoken_token_index'); |
|
| 535 | + $table->addIndex(['last_activity'], 'authtoken_last_activity_idx'); |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + if (!$schema->hasTable('bruteforce_attempts')) { |
|
| 539 | + $table = $schema->createTable('bruteforce_attempts'); |
|
| 540 | + $table->addColumn('id', 'integer', [ |
|
| 541 | + 'autoincrement' => true, |
|
| 542 | + 'notnull' => true, |
|
| 543 | + 'length' => 4, |
|
| 544 | + 'unsigned' => true, |
|
| 545 | + ]); |
|
| 546 | + $table->addColumn('action', 'string', [ |
|
| 547 | + 'notnull' => true, |
|
| 548 | + 'length' => 64, |
|
| 549 | + 'default' => '', |
|
| 550 | + ]); |
|
| 551 | + $table->addColumn('occurred', 'integer', [ |
|
| 552 | + 'notnull' => true, |
|
| 553 | + 'length' => 4, |
|
| 554 | + 'default' => 0, |
|
| 555 | + 'unsigned' => true, |
|
| 556 | + ]); |
|
| 557 | + $table->addColumn('ip', 'string', [ |
|
| 558 | + 'notnull' => true, |
|
| 559 | + 'length' => 255, |
|
| 560 | + 'default' => '', |
|
| 561 | + ]); |
|
| 562 | + $table->addColumn('subnet', 'string', [ |
|
| 563 | + 'notnull' => true, |
|
| 564 | + 'length' => 255, |
|
| 565 | + 'default' => '', |
|
| 566 | + ]); |
|
| 567 | + $table->addColumn('metadata', 'string', [ |
|
| 568 | + 'notnull' => true, |
|
| 569 | + 'length' => 255, |
|
| 570 | + 'default' => '', |
|
| 571 | + ]); |
|
| 572 | + $table->setPrimaryKey(['id']); |
|
| 573 | + $table->addIndex(['ip'], 'bruteforce_attempts_ip'); |
|
| 574 | + $table->addIndex(['subnet'], 'bruteforce_attempts_subnet'); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + if (!$schema->hasTable('vcategory')) { |
|
| 578 | + $table = $schema->createTable('vcategory'); |
|
| 579 | + $table->addColumn('id', 'integer', [ |
|
| 580 | + 'autoincrement' => true, |
|
| 581 | + 'notnull' => true, |
|
| 582 | + 'length' => 4, |
|
| 583 | + 'unsigned' => true, |
|
| 584 | + ]); |
|
| 585 | + $table->addColumn('uid', 'string', [ |
|
| 586 | + 'notnull' => true, |
|
| 587 | + 'length' => 64, |
|
| 588 | + 'default' => '', |
|
| 589 | + ]); |
|
| 590 | + $table->addColumn('type', 'string', [ |
|
| 591 | + 'notnull' => true, |
|
| 592 | + 'length' => 64, |
|
| 593 | + 'default' => '', |
|
| 594 | + ]); |
|
| 595 | + $table->addColumn('category', 'string', [ |
|
| 596 | + 'notnull' => true, |
|
| 597 | + 'length' => 255, |
|
| 598 | + 'default' => '', |
|
| 599 | + ]); |
|
| 600 | + $table->setPrimaryKey(['id']); |
|
| 601 | + $table->addIndex(['uid'], 'uid_index'); |
|
| 602 | + $table->addIndex(['type'], 'type_index'); |
|
| 603 | + $table->addIndex(['category'], 'category_index'); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + if (!$schema->hasTable('vcategory_to_object')) { |
|
| 607 | + $table = $schema->createTable('vcategory_to_object'); |
|
| 608 | + $table->addColumn('objid', 'integer', [ |
|
| 609 | + 'notnull' => true, |
|
| 610 | + 'length' => 4, |
|
| 611 | + 'default' => 0, |
|
| 612 | + 'unsigned' => true, |
|
| 613 | + ]); |
|
| 614 | + $table->addColumn('categoryid', 'integer', [ |
|
| 615 | + 'notnull' => true, |
|
| 616 | + 'length' => 4, |
|
| 617 | + 'default' => 0, |
|
| 618 | + 'unsigned' => true, |
|
| 619 | + ]); |
|
| 620 | + $table->addColumn('type', 'string', [ |
|
| 621 | + 'notnull' => true, |
|
| 622 | + 'length' => 64, |
|
| 623 | + 'default' => '', |
|
| 624 | + ]); |
|
| 625 | + $table->setPrimaryKey(['categoryid', 'objid', 'type']); |
|
| 626 | + $table->addIndex(['objid', 'type'], 'vcategory_objectd_index'); |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + if (!$schema->hasTable('systemtag')) { |
|
| 630 | + $table = $schema->createTable('systemtag'); |
|
| 631 | + $table->addColumn('id', 'integer', [ |
|
| 632 | + 'autoincrement' => true, |
|
| 633 | + 'notnull' => true, |
|
| 634 | + 'length' => 4, |
|
| 635 | + 'unsigned' => true, |
|
| 636 | + ]); |
|
| 637 | + $table->addColumn('name', 'string', [ |
|
| 638 | + 'notnull' => true, |
|
| 639 | + 'length' => 64, |
|
| 640 | + 'default' => '', |
|
| 641 | + ]); |
|
| 642 | + $table->addColumn('visibility', 'smallint', [ |
|
| 643 | + 'notnull' => true, |
|
| 644 | + 'length' => 1, |
|
| 645 | + 'default' => 1, |
|
| 646 | + ]); |
|
| 647 | + $table->addColumn('editable', 'smallint', [ |
|
| 648 | + 'notnull' => true, |
|
| 649 | + 'length' => 1, |
|
| 650 | + 'default' => 1, |
|
| 651 | + ]); |
|
| 652 | + $table->setPrimaryKey(['id']); |
|
| 653 | + $table->addUniqueIndex(['name', 'visibility', 'editable'], 'tag_ident'); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + if (!$schema->hasTable('systemtag_object_mapping')) { |
|
| 657 | + $table = $schema->createTable('systemtag_object_mapping'); |
|
| 658 | + $table->addColumn('objectid', 'string', [ |
|
| 659 | + 'notnull' => true, |
|
| 660 | + 'length' => 64, |
|
| 661 | + 'default' => '', |
|
| 662 | + ]); |
|
| 663 | + $table->addColumn('objecttype', 'string', [ |
|
| 664 | + 'notnull' => true, |
|
| 665 | + 'length' => 64, |
|
| 666 | + 'default' => '', |
|
| 667 | + ]); |
|
| 668 | + $table->addColumn('systemtagid', 'integer', [ |
|
| 669 | + 'notnull' => true, |
|
| 670 | + 'length' => 4, |
|
| 671 | + 'default' => 0, |
|
| 672 | + 'unsigned' => true, |
|
| 673 | + ]); |
|
| 674 | + $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + if (!$schema->hasTable('systemtag_group')) { |
|
| 678 | + $table = $schema->createTable('systemtag_group'); |
|
| 679 | + $table->addColumn('systemtagid', 'integer', [ |
|
| 680 | + 'notnull' => true, |
|
| 681 | + 'length' => 4, |
|
| 682 | + 'default' => 0, |
|
| 683 | + 'unsigned' => true, |
|
| 684 | + ]); |
|
| 685 | + $table->addColumn('gid', 'string', [ |
|
| 686 | + 'notnull' => true, |
|
| 687 | + ]); |
|
| 688 | + $table->setPrimaryKey(['gid', 'systemtagid']); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + if (!$schema->hasTable('file_locks')) { |
|
| 692 | + $table = $schema->createTable('file_locks'); |
|
| 693 | + $table->addColumn('id', 'integer', [ |
|
| 694 | + 'autoincrement' => true, |
|
| 695 | + 'notnull' => true, |
|
| 696 | + 'length' => 4, |
|
| 697 | + 'unsigned' => true, |
|
| 698 | + ]); |
|
| 699 | + $table->addColumn('lock', 'integer', [ |
|
| 700 | + 'notnull' => true, |
|
| 701 | + 'length' => 4, |
|
| 702 | + 'default' => 0, |
|
| 703 | + ]); |
|
| 704 | + $table->addColumn('key', 'string', [ |
|
| 705 | + 'notnull' => true, |
|
| 706 | + 'length' => 64, |
|
| 707 | + ]); |
|
| 708 | + $table->addColumn('ttl', 'integer', [ |
|
| 709 | + 'notnull' => true, |
|
| 710 | + 'length' => 4, |
|
| 711 | + 'default' => -1, |
|
| 712 | + ]); |
|
| 713 | + $table->setPrimaryKey(['id']); |
|
| 714 | + $table->addUniqueIndex(['key'], 'lock_key_index'); |
|
| 715 | + $table->addIndex(['ttl'], 'lock_ttl_index'); |
|
| 716 | + } |
|
| 717 | + |
|
| 718 | + if (!$schema->hasTable('comments')) { |
|
| 719 | + $table = $schema->createTable('comments'); |
|
| 720 | + $table->addColumn('id', 'integer', [ |
|
| 721 | + 'autoincrement' => true, |
|
| 722 | + 'notnull' => true, |
|
| 723 | + 'length' => 4, |
|
| 724 | + 'unsigned' => true, |
|
| 725 | + ]); |
|
| 726 | + $table->addColumn('parent_id', 'integer', [ |
|
| 727 | + 'notnull' => true, |
|
| 728 | + 'length' => 4, |
|
| 729 | + 'default' => 0, |
|
| 730 | + 'unsigned' => true, |
|
| 731 | + ]); |
|
| 732 | + $table->addColumn('topmost_parent_id', 'integer', [ |
|
| 733 | + 'notnull' => true, |
|
| 734 | + 'length' => 4, |
|
| 735 | + 'default' => 0, |
|
| 736 | + 'unsigned' => true, |
|
| 737 | + ]); |
|
| 738 | + $table->addColumn('children_count', 'integer', [ |
|
| 739 | + 'notnull' => true, |
|
| 740 | + 'length' => 4, |
|
| 741 | + 'default' => 0, |
|
| 742 | + 'unsigned' => true, |
|
| 743 | + ]); |
|
| 744 | + $table->addColumn('actor_type', 'string', [ |
|
| 745 | + 'notnull' => true, |
|
| 746 | + 'length' => 64, |
|
| 747 | + 'default' => '', |
|
| 748 | + ]); |
|
| 749 | + $table->addColumn('actor_id', 'string', [ |
|
| 750 | + 'notnull' => true, |
|
| 751 | + 'length' => 64, |
|
| 752 | + 'default' => '', |
|
| 753 | + ]); |
|
| 754 | + $table->addColumn('message', 'text', [ |
|
| 755 | + 'notnull' => false, |
|
| 756 | + ]); |
|
| 757 | + $table->addColumn('verb', 'string', [ |
|
| 758 | + 'notnull' => false, |
|
| 759 | + 'length' => 64, |
|
| 760 | + ]); |
|
| 761 | + $table->addColumn('creation_timestamp', 'datetime', [ |
|
| 762 | + 'notnull' => false, |
|
| 763 | + ]); |
|
| 764 | + $table->addColumn('latest_child_timestamp', 'datetime', [ |
|
| 765 | + 'notnull' => false, |
|
| 766 | + ]); |
|
| 767 | + $table->addColumn('object_type', 'string', [ |
|
| 768 | + 'notnull' => true, |
|
| 769 | + 'length' => 64, |
|
| 770 | + 'default' => '', |
|
| 771 | + ]); |
|
| 772 | + $table->addColumn('object_id', 'string', [ |
|
| 773 | + 'notnull' => true, |
|
| 774 | + 'length' => 64, |
|
| 775 | + 'default' => '', |
|
| 776 | + ]); |
|
| 777 | + $table->addColumn('reference_id', 'string', [ |
|
| 778 | + 'notnull' => false, |
|
| 779 | + 'length' => 64, |
|
| 780 | + ]); |
|
| 781 | + $table->setPrimaryKey(['id']); |
|
| 782 | + $table->addIndex(['parent_id'], 'comments_parent_id_index'); |
|
| 783 | + $table->addIndex(['topmost_parent_id'], 'comments_topmost_parent_id_idx'); |
|
| 784 | + $table->addIndex(['object_type', 'object_id', 'creation_timestamp'], 'comments_object_index'); |
|
| 785 | + $table->addIndex(['actor_type', 'actor_id'], 'comments_actor_index'); |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + if (!$schema->hasTable('comments_read_markers')) { |
|
| 789 | + $table = $schema->createTable('comments_read_markers'); |
|
| 790 | + $table->addColumn('user_id', 'string', [ |
|
| 791 | + 'notnull' => true, |
|
| 792 | + 'length' => 64, |
|
| 793 | + 'default' => '', |
|
| 794 | + ]); |
|
| 795 | + $table->addColumn('marker_datetime', 'datetime', [ |
|
| 796 | + 'notnull' => false, |
|
| 797 | + ]); |
|
| 798 | + $table->addColumn('object_type', 'string', [ |
|
| 799 | + 'notnull' => true, |
|
| 800 | + 'length' => 64, |
|
| 801 | + 'default' => '', |
|
| 802 | + ]); |
|
| 803 | + $table->addColumn('object_id', 'string', [ |
|
| 804 | + 'notnull' => true, |
|
| 805 | + 'length' => 64, |
|
| 806 | + 'default' => '', |
|
| 807 | + ]); |
|
| 808 | + $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); |
|
| 809 | + $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); |
|
| 810 | + } |
|
| 811 | + |
|
| 812 | + if (!$schema->hasTable('credentials')) { |
|
| 813 | + $table = $schema->createTable('credentials'); |
|
| 814 | + $table->addColumn('user', 'string', [ |
|
| 815 | + 'notnull' => true, |
|
| 816 | + 'length' => 64, |
|
| 817 | + ]); |
|
| 818 | + $table->addColumn('identifier', 'string', [ |
|
| 819 | + 'notnull' => true, |
|
| 820 | + 'length' => 64, |
|
| 821 | + ]); |
|
| 822 | + $table->addColumn('credentials', 'text', [ |
|
| 823 | + 'notnull' => false, |
|
| 824 | + ]); |
|
| 825 | + $table->setPrimaryKey(['user', 'identifier']); |
|
| 826 | + $table->addIndex(['user'], 'credentials_user'); |
|
| 827 | + } |
|
| 828 | + |
|
| 829 | + if (!$schema->hasTable('admin_sections')) { |
|
| 830 | + $table = $schema->createTable('admin_sections'); |
|
| 831 | + $table->addColumn('id', 'string', [ |
|
| 832 | + 'notnull' => true, |
|
| 833 | + 'length' => 64, |
|
| 834 | + ]); |
|
| 835 | + $table->addColumn('class', 'string', [ |
|
| 836 | + 'notnull' => true, |
|
| 837 | + 'length' => 255, |
|
| 838 | + 'default' => '', |
|
| 839 | + ]); |
|
| 840 | + $table->addColumn('priority', 'smallint', [ |
|
| 841 | + 'notnull' => true, |
|
| 842 | + 'length' => 1, |
|
| 843 | + 'default' => 0, |
|
| 844 | + ]); |
|
| 845 | + $table->setPrimaryKey(['id']); |
|
| 846 | + $table->addUniqueIndex(['class'], 'admin_sections_class'); |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + if (!$schema->hasTable('admin_settings')) { |
|
| 850 | + $table = $schema->createTable('admin_settings'); |
|
| 851 | + $table->addColumn('id', 'integer', [ |
|
| 852 | + 'autoincrement' => true, |
|
| 853 | + 'notnull' => true, |
|
| 854 | + 'length' => 4, |
|
| 855 | + ]); |
|
| 856 | + $table->addColumn('class', 'string', [ |
|
| 857 | + 'notnull' => true, |
|
| 858 | + 'length' => 255, |
|
| 859 | + 'default' => '', |
|
| 860 | + ]); |
|
| 861 | + $table->addColumn('section', 'string', [ |
|
| 862 | + 'notnull' => false, |
|
| 863 | + 'length' => 64, |
|
| 864 | + ]); |
|
| 865 | + $table->addColumn('priority', 'smallint', [ |
|
| 866 | + 'notnull' => true, |
|
| 867 | + 'length' => 1, |
|
| 868 | + 'default' => 0, |
|
| 869 | + ]); |
|
| 870 | + $table->setPrimaryKey(['id']); |
|
| 871 | + $table->addUniqueIndex(['class'], 'admin_settings_class'); |
|
| 872 | + $table->addIndex(['section'], 'admin_settings_section'); |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + if (!$schema->hasTable('personal_sections')) { |
|
| 876 | + $table = $schema->createTable('personal_sections'); |
|
| 877 | + $table->addColumn('id', 'string', [ |
|
| 878 | + 'notnull' => true, |
|
| 879 | + 'length' => 64, |
|
| 880 | + ]); |
|
| 881 | + $table->addColumn('class', 'string', [ |
|
| 882 | + 'notnull' => true, |
|
| 883 | + 'length' => 255, |
|
| 884 | + 'default' => '', |
|
| 885 | + ]); |
|
| 886 | + $table->addColumn('priority', 'smallint', [ |
|
| 887 | + 'notnull' => true, |
|
| 888 | + 'length' => 1, |
|
| 889 | + 'default' => 0, |
|
| 890 | + ]); |
|
| 891 | + $table->setPrimaryKey(['id']); |
|
| 892 | + $table->addUniqueIndex(['class'], 'personal_sections_class'); |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + if (!$schema->hasTable('personal_settings')) { |
|
| 896 | + $table = $schema->createTable('personal_settings'); |
|
| 897 | + $table->addColumn('id', 'integer', [ |
|
| 898 | + 'autoincrement' => true, |
|
| 899 | + 'notnull' => true, |
|
| 900 | + 'length' => 4, |
|
| 901 | + ]); |
|
| 902 | + $table->addColumn('class', 'string', [ |
|
| 903 | + 'notnull' => true, |
|
| 904 | + 'length' => 255, |
|
| 905 | + 'default' => '', |
|
| 906 | + ]); |
|
| 907 | + $table->addColumn('section', 'string', [ |
|
| 908 | + 'notnull' => false, |
|
| 909 | + 'length' => 64, |
|
| 910 | + ]); |
|
| 911 | + $table->addColumn('priority', 'smallint', [ |
|
| 912 | + 'notnull' => true, |
|
| 913 | + 'length' => 1, |
|
| 914 | + 'default' => 0, |
|
| 915 | + ]); |
|
| 916 | + $table->setPrimaryKey(['id']); |
|
| 917 | + $table->addUniqueIndex(['class'], 'personal_settings_class'); |
|
| 918 | + $table->addIndex(['section'], 'personal_settings_section'); |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + if (!$schema->hasTable('accounts')) { |
|
| 922 | + $table = $schema->createTable('accounts'); |
|
| 923 | + $table->addColumn('uid', 'string', [ |
|
| 924 | + 'notnull' => true, |
|
| 925 | + 'length' => 64, |
|
| 926 | + 'default' => '', |
|
| 927 | + ]); |
|
| 928 | + $table->addColumn('data', 'text', [ |
|
| 929 | + 'notnull' => true, |
|
| 930 | + 'default' => '', |
|
| 931 | + ]); |
|
| 932 | + $table->setPrimaryKey(['uid']); |
|
| 933 | + } |
|
| 934 | + return $schema; |
|
| 935 | + } |
|
| 936 | 936 | } |
@@ -54,148 +54,148 @@ |
||
| 54 | 54 | * @package OC\Core |
| 55 | 55 | */ |
| 56 | 56 | class Application extends App { |
| 57 | - public function __construct() { |
|
| 58 | - parent::__construct('core'); |
|
| 59 | - |
|
| 60 | - $container = $this->getContainer(); |
|
| 61 | - |
|
| 62 | - $container->registerService('defaultMailAddress', function () { |
|
| 63 | - return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
| 64 | - }); |
|
| 65 | - |
|
| 66 | - $server = $container->getServer(); |
|
| 67 | - /** @var IEventDispatcher $eventDispatcher */ |
|
| 68 | - $eventDispatcher = $server->query(IEventDispatcher::class); |
|
| 69 | - |
|
| 70 | - $notificationManager = $server->getNotificationManager(); |
|
| 71 | - $notificationManager->registerNotifierService(RemoveLinkSharesNotifier::class); |
|
| 72 | - $notificationManager->registerNotifierService(AuthenticationNotifier::class); |
|
| 73 | - |
|
| 74 | - $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
|
| 75 | - function (GenericEvent $event) use ($container) { |
|
| 76 | - /** @var MissingIndexInformation $subject */ |
|
| 77 | - $subject = $event->getSubject(); |
|
| 78 | - |
|
| 79 | - $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 80 | - |
|
| 81 | - if ($schema->hasTable('share')) { |
|
| 82 | - $table = $schema->getTable('share'); |
|
| 83 | - |
|
| 84 | - if (!$table->hasIndex('share_with_index')) { |
|
| 85 | - $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
|
| 86 | - } |
|
| 87 | - if (!$table->hasIndex('parent_index')) { |
|
| 88 | - $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
|
| 89 | - } |
|
| 90 | - if (!$table->hasIndex('owner_index')) { |
|
| 91 | - $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
|
| 92 | - } |
|
| 93 | - if (!$table->hasIndex('initiator_index')) { |
|
| 94 | - $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - if ($schema->hasTable('filecache')) { |
|
| 99 | - $table = $schema->getTable('filecache'); |
|
| 100 | - |
|
| 101 | - if (!$table->hasIndex('fs_mtime')) { |
|
| 102 | - $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - if ($schema->hasTable('twofactor_providers')) { |
|
| 107 | - $table = $schema->getTable('twofactor_providers'); |
|
| 108 | - |
|
| 109 | - if (!$table->hasIndex('twofactor_providers_uid')) { |
|
| 110 | - $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if ($schema->hasTable('login_flow_v2')) { |
|
| 115 | - $table = $schema->getTable('login_flow_v2'); |
|
| 116 | - |
|
| 117 | - if (!$table->hasIndex('poll_token')) { |
|
| 118 | - $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
|
| 119 | - } |
|
| 120 | - if (!$table->hasIndex('login_token')) { |
|
| 121 | - $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
|
| 122 | - } |
|
| 123 | - if (!$table->hasIndex('timestamp')) { |
|
| 124 | - $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ($schema->hasTable('whats_new')) { |
|
| 129 | - $table = $schema->getTable('whats_new'); |
|
| 130 | - |
|
| 131 | - if (!$table->hasIndex('version')) { |
|
| 132 | - $subject->addHintForMissingSubject($table->getName(), 'version'); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if ($schema->hasTable('cards')) { |
|
| 137 | - $table = $schema->getTable('cards'); |
|
| 138 | - |
|
| 139 | - if (!$table->hasIndex('cards_abid')) { |
|
| 140 | - $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - if ($schema->hasTable('cards_properties')) { |
|
| 145 | - $table = $schema->getTable('cards_properties'); |
|
| 146 | - |
|
| 147 | - if (!$table->hasIndex('cards_prop_abid')) { |
|
| 148 | - $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($schema->hasTable('calendarobjects_props')) { |
|
| 153 | - $table = $schema->getTable('calendarobjects_props'); |
|
| 154 | - |
|
| 155 | - if (!$table->hasIndex('calendarobject_calid_index')) { |
|
| 156 | - $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if ($schema->hasTable('schedulingobjects')) { |
|
| 161 | - $table = $schema->getTable('schedulingobjects'); |
|
| 162 | - if (!$table->hasIndex('schedulobj_principuri_index')) { |
|
| 163 | - $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - if ($schema->hasTable('properties')) { |
|
| 168 | - $table = $schema->getTable('properties'); |
|
| 169 | - if (!$table->hasIndex('properties_path_index')) { |
|
| 170 | - $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - ); |
|
| 175 | - |
|
| 176 | - $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
|
| 177 | - function (GenericEvent $event) use ($container) { |
|
| 178 | - /** @var MissingColumnInformation $subject */ |
|
| 179 | - $subject = $event->getSubject(); |
|
| 180 | - |
|
| 181 | - $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 182 | - |
|
| 183 | - if ($schema->hasTable('comments')) { |
|
| 184 | - $table = $schema->getTable('comments'); |
|
| 185 | - |
|
| 186 | - if (!$table->hasColumn('reference_id')) { |
|
| 187 | - $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - ); |
|
| 192 | - |
|
| 193 | - $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
|
| 194 | - $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
|
| 195 | - $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
|
| 196 | - $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
|
| 197 | - $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
|
| 198 | - $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
|
| 199 | - $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
|
| 200 | - } |
|
| 57 | + public function __construct() { |
|
| 58 | + parent::__construct('core'); |
|
| 59 | + |
|
| 60 | + $container = $this->getContainer(); |
|
| 61 | + |
|
| 62 | + $container->registerService('defaultMailAddress', function () { |
|
| 63 | + return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
| 64 | + }); |
|
| 65 | + |
|
| 66 | + $server = $container->getServer(); |
|
| 67 | + /** @var IEventDispatcher $eventDispatcher */ |
|
| 68 | + $eventDispatcher = $server->query(IEventDispatcher::class); |
|
| 69 | + |
|
| 70 | + $notificationManager = $server->getNotificationManager(); |
|
| 71 | + $notificationManager->registerNotifierService(RemoveLinkSharesNotifier::class); |
|
| 72 | + $notificationManager->registerNotifierService(AuthenticationNotifier::class); |
|
| 73 | + |
|
| 74 | + $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT, |
|
| 75 | + function (GenericEvent $event) use ($container) { |
|
| 76 | + /** @var MissingIndexInformation $subject */ |
|
| 77 | + $subject = $event->getSubject(); |
|
| 78 | + |
|
| 79 | + $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 80 | + |
|
| 81 | + if ($schema->hasTable('share')) { |
|
| 82 | + $table = $schema->getTable('share'); |
|
| 83 | + |
|
| 84 | + if (!$table->hasIndex('share_with_index')) { |
|
| 85 | + $subject->addHintForMissingSubject($table->getName(), 'share_with_index'); |
|
| 86 | + } |
|
| 87 | + if (!$table->hasIndex('parent_index')) { |
|
| 88 | + $subject->addHintForMissingSubject($table->getName(), 'parent_index'); |
|
| 89 | + } |
|
| 90 | + if (!$table->hasIndex('owner_index')) { |
|
| 91 | + $subject->addHintForMissingSubject($table->getName(), 'owner_index'); |
|
| 92 | + } |
|
| 93 | + if (!$table->hasIndex('initiator_index')) { |
|
| 94 | + $subject->addHintForMissingSubject($table->getName(), 'initiator_index'); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + if ($schema->hasTable('filecache')) { |
|
| 99 | + $table = $schema->getTable('filecache'); |
|
| 100 | + |
|
| 101 | + if (!$table->hasIndex('fs_mtime')) { |
|
| 102 | + $subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + if ($schema->hasTable('twofactor_providers')) { |
|
| 107 | + $table = $schema->getTable('twofactor_providers'); |
|
| 108 | + |
|
| 109 | + if (!$table->hasIndex('twofactor_providers_uid')) { |
|
| 110 | + $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if ($schema->hasTable('login_flow_v2')) { |
|
| 115 | + $table = $schema->getTable('login_flow_v2'); |
|
| 116 | + |
|
| 117 | + if (!$table->hasIndex('poll_token')) { |
|
| 118 | + $subject->addHintForMissingSubject($table->getName(), 'poll_token'); |
|
| 119 | + } |
|
| 120 | + if (!$table->hasIndex('login_token')) { |
|
| 121 | + $subject->addHintForMissingSubject($table->getName(), 'login_token'); |
|
| 122 | + } |
|
| 123 | + if (!$table->hasIndex('timestamp')) { |
|
| 124 | + $subject->addHintForMissingSubject($table->getName(), 'timestamp'); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ($schema->hasTable('whats_new')) { |
|
| 129 | + $table = $schema->getTable('whats_new'); |
|
| 130 | + |
|
| 131 | + if (!$table->hasIndex('version')) { |
|
| 132 | + $subject->addHintForMissingSubject($table->getName(), 'version'); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if ($schema->hasTable('cards')) { |
|
| 137 | + $table = $schema->getTable('cards'); |
|
| 138 | + |
|
| 139 | + if (!$table->hasIndex('cards_abid')) { |
|
| 140 | + $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + if ($schema->hasTable('cards_properties')) { |
|
| 145 | + $table = $schema->getTable('cards_properties'); |
|
| 146 | + |
|
| 147 | + if (!$table->hasIndex('cards_prop_abid')) { |
|
| 148 | + $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($schema->hasTable('calendarobjects_props')) { |
|
| 153 | + $table = $schema->getTable('calendarobjects_props'); |
|
| 154 | + |
|
| 155 | + if (!$table->hasIndex('calendarobject_calid_index')) { |
|
| 156 | + $subject->addHintForMissingSubject($table->getName(), 'calendarobject_calid_index'); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if ($schema->hasTable('schedulingobjects')) { |
|
| 161 | + $table = $schema->getTable('schedulingobjects'); |
|
| 162 | + if (!$table->hasIndex('schedulobj_principuri_index')) { |
|
| 163 | + $subject->addHintForMissingSubject($table->getName(), 'schedulobj_principuri_index'); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + if ($schema->hasTable('properties')) { |
|
| 168 | + $table = $schema->getTable('properties'); |
|
| 169 | + if (!$table->hasIndex('properties_path_index')) { |
|
| 170 | + $subject->addHintForMissingSubject($table->getName(), 'properties_path_index'); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + ); |
|
| 175 | + |
|
| 176 | + $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, |
|
| 177 | + function (GenericEvent $event) use ($container) { |
|
| 178 | + /** @var MissingColumnInformation $subject */ |
|
| 179 | + $subject = $event->getSubject(); |
|
| 180 | + |
|
| 181 | + $schema = new SchemaWrapper($container->query(IDBConnection::class)); |
|
| 182 | + |
|
| 183 | + if ($schema->hasTable('comments')) { |
|
| 184 | + $table = $schema->getTable('comments'); |
|
| 185 | + |
|
| 186 | + if (!$table->hasColumn('reference_id')) { |
|
| 187 | + $subject->addHintForMissingColumn($table->getName(), 'reference_id'); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + ); |
|
| 192 | + |
|
| 193 | + $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); |
|
| 194 | + $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); |
|
| 195 | + $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); |
|
| 196 | + $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); |
|
| 197 | + $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); |
|
| 198 | + $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); |
|
| 199 | + $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); |
|
| 200 | + } |
|
| 201 | 201 | } |