Ich habe versucht, die folgenden 3 Codes in einem Laravel 5.3-Projekt zu verwenden, um eine neue Dezimalspalte zu einer vorhandenen Tabelle hinzuzufügen. Aber es gibt jedes Mal denselben Fehler.Wie man eine Dezimalspalte zu einer vorhandenen Tabelle in Laravel hinzufügt 5.3 Migration
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost');
});
und
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>0]);
});
und
Schema::table('mileages', function (Blueprint $table) {
$table->addColumn('decimal', 'cost', ['default'=>'0,0']);
});
Der Fehler war:
[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 (,) not null)
ich etwas fehle?
Ja, es funktioniert. Vielen Dank!. Auch '$ table-> addColumn ('dezimal', 'cost', ['default' => 0, 'total' => 8, 'places' => 2]);' funktioniert. – Eranda