在Laravel中态蒂,使用migration作為數(shù)據(jù)庫的版本控制工具骡苞,當(dāng)需要對(duì)已存在的數(shù)據(jù)表作更改,需要額外引入doctrine/dbal擴(kuò)展喘先。
在一次使用中钳吟,對(duì)數(shù)據(jù)表中的某個(gè)字段的評(píng)論進(jìn)行了更改,在php artisan migrate
的時(shí)候窘拯,拋出一下異常:
[Doctrine\DBAL\DBALException]
Unknown column type "double" 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 kn
own types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgot to register all database types f
or 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.
上面問題出現(xiàn)的原因红且,是migration 提供的數(shù)據(jù)類型和doctrine/dbal提供的數(shù)據(jù)類型存在著差異。即在migration中提供了double類型的接口涤姊,而doctrine/dbal中只存在float暇番。
解決辦法是,參考doctrine/dbal文檔提供的數(shù)據(jù)類型來進(jìn)行更改:doctrine/dbal 類型