ModifyColumn.php 789 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Migration\Attributes;
  8. use Attribute;
  9. /**
  10. * attribute on column modification
  11. *
  12. * @since 30.0.0
  13. */
  14. #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
  15. class ModifyColumn extends ColumnMigrationAttribute {
  16. /**
  17. * @return string
  18. * @since 30.0.0
  19. */
  20. public function definition(): string {
  21. $type = is_null($this->getType()) ? '' : ' to ' . $this->getType()->value;
  22. return empty($this->getName()) ?
  23. 'Modification of a column from table \'' . $this->getTable() . '\'' . $type
  24. : 'Modification of column \'' . $this->getName() . '\' from table \'' . $this->getTable() . '\'' . $type;
  25. }
  26. }