Home > Software engineering >  Laravel: Unknown column type "timestamp" requested
Laravel: Unknown column type "timestamp" requested

Time:02-17

I am trying to perform a migration and I am getting the following problem.

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

My code is the following:

Schema::table('XXXXXXXX', function (Blueprint $table) {
        $table->timestamp('start')->change();
        $table->timestamp('end')->change();
    });

The strange thing is that I have already performed migrations with that type of data:

Schema::create('XXXXXX', function (Blueprint $table) {
        ...
        $table->timestamp('date_expired')->nullable();
        ...

    });

Does anyone know how to fix it or see the error I'm doing.

Thanks


UPDATE

In the end I have deleted the migration, I have modified it putting timestamp in the necessary columns and I have executed it again. (Having deleted the table before from the database)

CodePudding user response:

On the laravel docs page you can find a warning telling you that there are certain types that you can't use with the ->change() method.

Link to laravel docs

It also says this:

To modify a timestamp column type a Doctrine type must be registered.

  • Related