次の移行を適用しようとしています。
Schema::table('users', function (Blueprint $table) {
$table->timestamp('created_at')->useCurrent()->change();
});
しかし、次のartisan
ように述べています。
[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\DBAL\Types\Type::getTypesMap(). I
f this error occurs during database introspection then you might have forgot to register all database types for a
Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() 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 inform
ation.
mmerian/doctrine-timestamp
( composer install mmerian/doctrine-timestamp
)をインストールしようとすると、次のように表示されcomposer
ます。
[InvalidArgumentException]
Could not find package mmerian/doctrine-timestamp at any version for your minimum-stability (stable). Check the pa
ckage spelling or your minimum-stability
私は何をしますか?
UPD Withcomposer require mmerian/doctrine-timestamp=dev-master
で、パッケージをインストールしてからステートメントのType::addType('timestamp', 'DoctrineTimestamp\DBAL\Types\Timestamp');
前に追加できましたが、他のエラーが発生しました:Schema::table
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: ALTER TABLE u
sers CHANGE created_at created_at INT DEFAULT 'CURRENT_TIMESTAMP' NOT NULL)
UPDmmerian/doctrine-timestamp
当時のドキュメントの最初の行のみを追加したため(またはドキュメントが更新されたため)、で動作するかどうかを再度確認しました。
Type::addType('timestamp', 'DoctrineTimestamp\DBAL\Types\Timestamp');
DB::getDoctrineConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('Timestamp', 'timestamp');
しかし、それも役に立ちません。移行は成功しますが、列の定義は変更されません。