Linked Questions

Popular Questions

How to Disable Enum Check In Laravel

Asked by At

I want to add another new enum column in the table, but not able to migrate, as it says column already exists.

Migration

class DesignationColumnNullableInUserTable extends Migration
{
    public function __construct()
    {
        \Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
        ->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
        Type::addType('enum', \Doctrine\DBAL\Types\StringType::class);
    }

    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->enum('designation', ['Lawyer', 'Freelancer', 
                'Corporate secretary', 'Immigration Consultant'])
             ->nullable()->change();
        });
    }

    public function down()
    {
        Schema::table('user', function (Blueprint $table) {
            $table->dropIfExists('designation');
        });
    }
} 

I have also made some changes in another migration with a foreign key.

\Illuminate\Support\Facades\DB::getDoctrineSchemaManager()
    ->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');

How can I fix this issue for the enum check?

Related Questions