Search This Blog

Tuesday, October 17

How do I make doctrine support timestamp columns

Problem:

 [Doctrine\DBAL\DBALException]
  Unknown column type "timestamp" 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\DB
  AL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrine
  TypeMapping() 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.


Solution:

For everyone who is still coming across this issue via Google or something, there currently is an official way to support this. See this part of the docs.

Basically, you need to add the following to your config/database.php file:

'dbal' => [
    'types' => [
        'timestamp' => TimestampType::class,
    ],
],

 Make sure you add use Illuminate\Database\DBAL\TimestampType; as well ;)

No comments:

Post a Comment