1

I runed the command composer install in my Symfony project. However, when I attempted to run the command symfony console doctrine:schema:update, I encountered the error message:

Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.

I then modified my code line @ORM\Column(type="json_array") to @ORM\Column(type="json"), but the error persisted when I runed symfony console doctrine:schema:update

From what I understand, one of the sources of the problem is that when I executed the command composer show doctrine/dbal, it indicated that I was using version 3.8.2. However, just two days ago, when I executed the same command, I was still using version 2.13.2.

I came across this article https://dunglas.dev/2022/01/json-columns-and-doctrine-dbal-3-upgrade/, but unfortunately, I do not fully understand its content.

Thank you in advance for any assistance you can provide

1 Answer 1

3

First:

SELECT table_schema, table_name, column_name, column_comment
FROM information_schema.columns
WHERE column_comment LIKE '%(DC2Type:json_array)%';

Then for each of the resulting tables names:

ALTER TABLE <table_name> 
MODIFY COLUMN <column_name> longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json)';
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?
Thanks for the answer, worked like a charm! For those wo will use it too, do not forget to adapt the part COLLATE utf8mb4_unicode_ci to what is currently being used by your column.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.