小编Era*_*nda的帖子

如何在Laravel 5.3迁移中将十进制列添加到现有表

我尝试在Laravel 5.3项目中遵循3个代码,将新的十进制列添加到现有表中.但它每次都会给出同样的错误.

Schema::table('mileages', function (Blueprint $table) {
    $table->addColumn('decimal', 'cost');
});
Run Code Online (Sandbox Code Playgroud)

Schema::table('mileages', function (Blueprint $table) {
    $table->addColumn('decimal', 'cost', ['default'=>0]);
});
Run Code Online (Sandbox Code Playgroud)

Schema::table('mileages', function (Blueprint $table) {
    $table->addColumn('decimal', 'cost', ['default'=>'0,0']);
});
Run Code Online (Sandbox Code Playgroud)

错误是:

[Illuminate\Database\QueryException]                                                                                 
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that  
corresponds to your MariaDB server version for the right syntax to use near ' ) not null' at line 1 (SQL: alter table `mileages` add `cost` decimal (, ) …
Run Code Online (Sandbox Code Playgroud)

php laravel-5.3

4
推荐指数
1
解决办法
4856
查看次数

标签 统计

laravel-5.3 ×1

php ×1