Search code examples
symfonysymfony-sonata

Removing Sonata Bundles


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.


Solution

  • 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.