mercredi 26 octobre 2016

laravel migrate:rollback wrong

Laravel version 5.1.43(LTS)

I use php artisan migrate:rollback in terminal then return error messages. But the database is changed. Then I re-entered this command again there is no error messages.

Can anybody help me fix this problem?

[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP'user_id'; check that column/key exists (SQL: alter table crm_user drop index user_id)

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'user_id'; check that column/key exists

My migration code

public function down()
{
    if (Schema::hasColumn('crm_user', 'user_id')) {
        Schema::table('crm_user', function (Blueprint $table) {
            $table->dropColumn('user_id');
            $table->dropIndex('user_id');
        });
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire