Removing Sonata Bundles
Asked Answered
P

3

5

I installed several of the Sonata bundles (user, admin etc) on my Symfony 2 app but after using them for a while, I decided I didn't like them and wanted to remove them.

I've updated my composer.json and AppKernel.php files, removing anything to do with Sonata. I've also removed all of the relevant routes, configs and security file entries. However, I'm having trouble updating my database schema now.

I get the following error whenever I run one:

[Doctrine\DBAL\DBALException]                                                
  Unknown column type "json" requested. Any Doctrine type that you use has to  
   be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a lis  
  t of all the known types with \Doctrine\DBAL\Types\Type::getTypeMap(). If t  
  his error occurs during database introspection then you might have forgot t  
  o register all database types for a Doctrine Type. Use AbstractPlatform#reg  
  isterDoctrineTypeMapping() or have your custom types implement Type#getMapp  
  edDatabaseTypes(). If the type name is empty you might have a problem with   
  the cache or forgot some mapping information.

I know this is from the Doctrine configuration for one of the Sonata bundles:

# Doctrine Configuration doctrine:
dbal:
    driver:   %database_driver%
    host:     %database_host%
    port:     %database_port%
    dbname:   %database_name%
    user:     %database_user%
    password: %database_password%
    charset:  UTF8
    #types:
#    json: Sonata\Doctrine\Types\JsonType

As you can see, I've commented this out I'm still continuing to get the error.

I'm having trouble tracking down where this is still referenced.

Paget answered 24/7, 2013 at 19:33 Comment(1)
Don't you use json as a type on a column in one of your entity?Presume
V
3

I was getting this error (different column type), when I removed a field from entity and removed the type definition itself. There was no error, after I introduced back the type definition and only removed the field. I did schema update, then I could remove the type all together.

Maybe better solution for you would be to drop the database entirely and perform doctrine:schema:update from scratch then.

Valence answered 25/7, 2013 at 12:12 Comment(1)
this happened when sonata update the fos_user table in order it receive json information. So when I uninstalled sonata, I started to have this error but What I did is creating that Sonata\Doctrine\Type\JsonType into my Doctrine\Type . And It started to workMallard
C
9

I had the same issue as most people. There used to be an issue with installing SonataAdminBundle, but that's probably the problem if you're installing SonataAdminBundle and can't get things to work. If that's the case see this link: https://github.com/sonata-project/SonataAdminBundle/issues/811

In My case, and most other people here, this happened when removing SonataAdminBundle, for some reason it's hanging around like a bad smell. I tried removing the database and restoring it again among other things which didn't work.

So the following hack seems to get # Doctrine Configuration

doctrine:
    dbal:
        ...
        types: #this is about this line and line below
            json:     \Doctrine\DBAL\Types\StringType      

Definitely not a perfect workaround but should get things back to the way they were until you actually need JsonType and you can introduce the type then.

Calyptra answered 22/4, 2015 at 14:27 Comment(1)
JsonType was introduced in Doctrine 2.6. Until you can upgrade to this version, the correct mapping would be json: Doctrine\DBAL\Types\JsonArrayType.Ossicle
V
3

I was getting this error (different column type), when I removed a field from entity and removed the type definition itself. There was no error, after I introduced back the type definition and only removed the field. I did schema update, then I could remove the type all together.

Maybe better solution for you would be to drop the database entirely and perform doctrine:schema:update from scratch then.

Valence answered 25/7, 2013 at 12:12 Comment(1)
this happened when sonata update the fos_user table in order it receive json information. So when I uninstalled sonata, I started to have this error but What I did is creating that Sonata\Doctrine\Type\JsonType into my Doctrine\Type . And It started to workMallard
M
0

This happened to me after install sonataadminbundle and I uninstalled it after.

Sonata updates fos_user table in order it receive json information in "roles" column. So when I uninstalled sonata, I started to have this error but What I did is creating that Sonata\Doctrine\Type\JsonType into my Doctrine\Type . And It started to work.

Mallard answered 31/10, 2014 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.