使用迁移Laravel更改类型列

时间:2018-08-06 22:58:40

标签: laravel postgresql migration

我正在使用laravel 5.5.41,我需要更改数据库中列的类型。当前类型为varchar,应为date。日期以yy-mm-dd格式保存。 创建类型迁移时

Schema :: table ('users', function (Blueprint $ table) {
            $ table-> date (birthdate) -> change ();
        });

我收到以下错误:

SQLSTATE [42804]: Datatype mismatch: 7 ERROR: column "birthdate" can not be cast automatically to type date
  HINT: You might need to specify "USING birthdate :: date". (SQL: ALTER TABLE users ALTER birthdate TYPE DATE)

,如果我通过以下方式进行操作:

Schema::table('users', function (Blueprint $table) {
            $table->date("USING (birthdate::date)")->change();
        });

我收到以下错误:

In SchemaException.php line 89:                                                                   
  There is no column with name 'using (birthdate::date)' on table 'users'.  

我已经有了教义/ dbal

0 个答案:

没有答案