Version29000Date20240124132201.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Migrations;
  8. use Closure;
  9. use OCP\DB\ISchemaWrapper;
  10. use OCP\DB\Types;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\SimpleMigrationStep;
  13. /**
  14. * Create new column for type and remove previous lazy column in appconfig (will be recreated by Version29000Date20240124132202) for the new IAppConfig API.
  15. */
  16. class Version29000Date20240124132201 extends SimpleMigrationStep {
  17. public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
  18. /** @var ISchemaWrapper $schema */
  19. $schema = $schemaClosure();
  20. $table = $schema->getTable('appconfig');
  21. // we will drop 'lazy', we start to clean related indexes first
  22. if ($table->hasIndex('ac_lazy_i')) {
  23. $table->dropIndex('ac_lazy_i');
  24. }
  25. if ($table->hasIndex('ac_app_lazy_i')) {
  26. $table->dropIndex('ac_app_lazy_i');
  27. }
  28. if ($table->hasIndex('ac_app_lazy_key_i')) {
  29. $table->dropIndex('ac_app_lazy_key_i');
  30. }
  31. if ($table->hasColumn('lazy')) {
  32. $table->dropColumn('lazy');
  33. }
  34. // create field 'type' if it does not exist yet, or fix the fact that it is missing 'unsigned'
  35. if (!$table->hasColumn('type')) {
  36. $table->addColumn('type', Types::INTEGER, ['notnull' => true, 'default' => 2, 'unsigned' => true]);
  37. } else {
  38. $table->modifyColumn('type', ['notnull' => true, 'default' => 2, 'unsigned' => true]);
  39. }
  40. // not needed anymore
  41. if ($table->hasIndex('appconfig_config_key_index')) {
  42. $table->dropIndex('appconfig_config_key_index');
  43. }
  44. return $schema;
  45. }
  46. }