mardi 8 mai 2018

How to change column type from string to integer? Laravel 5

I have a column called owner_type in a table called events. This column is filled with one of two values: 0 (signalling regular users) and 1 (for business users).

This column has a data type string, I'd like to change it to integer given that it'll always contain 0s and 1s. So I did this:

public function up()
{
    Schema::table('events', function (Blueprint $table) {
        $table->integer('owner_type')->change()->default(0);
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('events', function (Blueprint $table) {
        $table->string('owner_type')->default(0)->change();
    });
}

However, I receive this error:

n AbstractPlatform.php line 461:

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

In the migration that created events I have:

    $table->enum('**', ['**', '**'])->default('**');
    $table->enum('status', ['*', '*', '*', '*', '*'])->default('*');

However, this table is already migrated. So what's wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire