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