Home > Mobile >  Syntax error or access violation: 1064 You have an error in your SQL syntax;that corresponds to your
Syntax error or access violation: 1064 You have an error in your SQL syntax;that corresponds to your

Time:09-22

public function up()
    {
        Schema::table('coupons', function (Blueprint $table) {
            $table->date('expiry_date')->default(DB::raw('CURRENT_DATE'));
        });
    }

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 MySQL server version for the right syntax to use near 'CURRENT_DATE' at line 1 (SQL: alter table coupons add expiry_date date not null default CURRENT_DATE)

CodePudding user response:

Please try this code:

$table->date('expiry_date')->default(Carbon::now());
  • Related