AddColumn.php 792 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 new column creation
  11. *
  12. * @since 30.0.0
  13. */
  14. #[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_CLASS)]
  15. class AddColumn extends ColumnMigrationAttribute {
  16. /**
  17. * @return string
  18. * @since 30.0.0
  19. */
  20. public function definition(): string {
  21. $type = is_null($this->getType()) ? '' : ' (' . $this->getType()->value . ')';
  22. return empty($this->getName()) ?
  23. 'Addition of a new column' . $type . ' to table \'' . $this->getTable() . '\''
  24. : 'Addition of column \'' . $this->getName() . '\'' . $type . ' to table \'' . $this->getTable() . '\'';
  25. }
  26. }