Tuesday, March 7, 2017

Removing columns from migration in Laravel 5.4

I created a table using migration like:

 Schema::create('listings', function (Blueprint $table) {
        $table->increments('id');
        $table->decimal('original_price', 10, 2);
        $table->decimal('discouted_price', 10, 2);

        $table->integer('city_id')->index()->unsigned()->nullable();
        $table->foreign('city_id')->references('id')->on('cities');

        $table->integer('destination_city_id')->unsigned()->index();
        $table->foreign('destination_city_id')->references('id')->on('cities');

        $table->string('url');
        $table->string('titile');
        $table->text('description')->nullable();
        $table->dateTime('expires_at');
        $table->integer('clicks')->default('0');
        $table->integer('views')->default('0');
        $table->timestamps();
        $table->softDeletes();
    });

Now i wanna remove this two colums from ('listings').

$table->integer('city_id')->index()->unsigned()->nullable();
        $table->foreign('city_id')->references('id')->on('cities');

        $table->integer('destination_city_id')->unsigned()->index();
        $table->foreign('destination_city_id')->references('id')->on('cities');

But someone can write the this new migration how must look for remove on this two columns ?



via Александър Белов

Advertisement