I am working with laravel 5.6 and PostgreSQL 9.6 and I am trying to change the datatype of a column date from date to integer using a migration below.
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeBidDateTypeInAucBiddingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('auc_biddings', function (Blueprint $table) {
//
$table->integer('bid_date')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('auc_biddings', function (Blueprint $table) {
//
$table->date('bid_date')->change();
});
}
}
But every time I run the migration I get the following error
In PDOStatement.php line 107:
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "bid_date" cannot be cast automatically to t ype integer HINT: You might need to specify "USING bid_date::integer".
Kindly assist on how I can achieve changing a column datatype using migration. Thanks
Below are some of the codes from composer.json
"require": {
"php": ">=7.0.0",
"doctrine/dbal": "^2.6",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"predis/predis": "~1.0",
"tymon/jwt-auth": "dev-develop"
},