I'm simply trying to add a new column to an existing table. This is my migration:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddWarehouse extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('routes', function (Blueprint $table){
$table->string('warehouse_address');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('routes', function (Blueprint $table){
$table->dropColumn(['warehouse_address']);
});
}
}
Running php artisan migrate caused the following errors:
[Illuminate\Database\QueryException]
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1 (SQL: alter table `routes` add `warehouse_address` varchar(255) not null)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1
[PDOException]
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00' for column 'created_at' at row 1
The table contains columns 'created_at' and 'updated_at' which are already filled with correct values. How do I stop Schema from trying to insert a datetime into the 'created_at' column? I would rather leave it alone.
Executing the commands in MySql works perfectly fine.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire