I have this:
$table->integer('role_id')->index()->unsigned()->nullable();
But I want to change it to this:
$table->integer('role_id')->index()->unsigned()->nullable()->default(3);
I had wanted to use this, but the source syntax I could not understand:
php artisan make:migration update_role_id_in_users --table=users
I even tried using doctrine/ddbal
package and running this:
php artisan make:migration modify_role_id_in_users --table=users
with the migration set up like this:
class ModifyRoleIdInUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
//
$table->integer('role_id')->index()->unsigned()->nullable()->default(3)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
//
$table->integer('role_id')->index()->unsigned()->nullable()->change();
});
}
}
But I get this error when I go migrate:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'users_role_id_index' (SQL: alter table 'users' add index 'users_role_id_index'('role_
id'))[Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'users_role_id_index'
[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1061 Duplicate key name 'users_role_id_index'
How can I alter the column
without doing a migrate:refresh