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