diff --git a/databox/api/config/validator/validation.yaml b/databox/api/config/validator/validation.yaml index cd0f018e9..089db42f7 100644 --- a/databox/api/config/validator/validation.yaml +++ b/databox/api/config/validator/validation.yaml @@ -48,7 +48,6 @@ App\Entity\Core\Attribute: App\Entity\Core\AbstractBaseAttribute: constraints: - - App\Validator\UniqueAttributeConstraint: ~ - App\Validator\ValidAttributeConstraint: ~ properties: value: diff --git a/databox/api/migrations/Version20230920160828.php b/databox/api/migrations/Version20230920160828.php new file mode 100644 index 000000000..5405ed920 --- /dev/null +++ b/databox/api/migrations/Version20230920160828.php @@ -0,0 +1,52 @@ +addSql('ALTER TABLE attribute_definition ALTER fallback TYPE JSON USING fallback::json'); + $this->addSql('COMMENT ON COLUMN attribute_definition.fallback IS NULL'); + $this->addSql('ALTER TABLE file ALTER alternate_urls TYPE JSON USING alternate_urls::json'); + $this->addSql('COMMENT ON COLUMN file.alternate_urls IS NULL'); + + $connection = $this->connection; + + foreach ([ + ['attribute_definition', 'fallback'], + ['file', 'alternate_urls'], + ] as $t) + { + [$table, $column] = $t; + $rows = $connection->fetchAllAssociative(sprintf('SELECT "id", "%s" FROM "%s"', $column, $table)); + + foreach ($rows as $row) { + $connection->executeStatement(sprintf('UPDATE "%s" SET "%s" = :encodedData WHERE id = :id', $table, $column), [ + 'encodedData' => json_encode(unserialize($row[$column])), + 'id' => $row['id'], + ]); + } + } + } + + public function down(Schema $schema): void + { + throw new \InvalidArgumentException('Cannot revert'); + } +} diff --git a/databox/api/src/Validator/ValidAttributeConstraintValidator.php b/databox/api/src/Validator/ValidAttributeConstraintValidator.php index a17cdcb37..f63847f56 100644 --- a/databox/api/src/Validator/ValidAttributeConstraintValidator.php +++ b/databox/api/src/Validator/ValidAttributeConstraintValidator.php @@ -5,7 +5,7 @@ namespace App\Validator; use App\Attribute\AttributeTypeRegistry; -use App\Entity\Core\Attribute; +use App\Entity\Core\AbstractBaseAttribute; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -16,7 +16,7 @@ public function __construct(private readonly AttributeTypeRegistry $typeRegistry } /** - * @param Attribute $value + * @param AbstractBaseAttribute $value * @param SameWorkspaceConstraint $constraint */ public function validate($value, Constraint $constraint): void diff --git a/lib/php/admin-bundle/Field/IdField.php b/lib/php/admin-bundle/Field/IdField.php index 0a1441ac1..893f9a453 100644 --- a/lib/php/admin-bundle/Field/IdField.php +++ b/lib/php/admin-bundle/Field/IdField.php @@ -15,6 +15,7 @@ public static function new(string $propertyName = 'id', $label = null): BaseIdFi } return BaseIdField::new($propertyName, $label) + ->hideOnForm() ->setTemplatePath('@AlchemyAdmin/list/id.html.twig'); } }