0

I'm trying to build a simple migration table and then trying to add a column in the table so following is my migration file:

class AddFlagToEmiTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('epins', function (Blueprint $table) {
            $table->boolean('flag');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */ 
    public function down()
    {
        Schema::table('epins', function (Blueprint $table) {
            //
        });
    }
}

In this I forgot to write the drop value which is:

$table->dropColumn('flag');

Now while adding this and trying to rollback and again the trying to do php artisan migrate it is showing error, and also it is showing output nothing to migrate respectively even I've added drop values in the migration.

I've already tried following:

php artisan optimize
php artisan clear-compiled
composer dump-autoload

It ain't helping me out please see the screenshot:

enter image description here

Help me out. Thanks!

Nitish Kumar
  • 6,054
  • 21
  • 82
  • 148

2 Answers2

1

its because artisan cannot find flag column in epins table

There is workaround for this,

add flagcolumn explicitly from phpmyadmin(if you are using mysql) and then try roll back

Hope this method works, ask if any doubt

kapilpatwa93
  • 4,111
  • 2
  • 13
  • 22
0

Please try deleting the tables from the database, modify the migration files and add drop to the down function and migrate again.

rahul
  • 496
  • 4
  • 17
  • you mean I need to delete the whole migration file? or only the `add_flag_to_epins_table`. As I'm adding the column. – Nitish Kumar Dec 04 '16 at 13:39
  • go to your phpmyadmin and add the flag column manually. `ALTER TABLE epins ADD flag boolean` – rahul Dec 04 '16 at 13:40