vendredi 25 mars 2016

What should I put in my down function when truncate a table in Laravel migration?

I'm trying to write a migration script to truncate my vistors table. We usually place the revert of the up function in the down function.

But in this case, it's a truncate, what should I put in my down function ?

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class TruncateVisitorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
       DB::table('visitors')->truncate();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // what should I put here ? 
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire