Skip to content

Instantly share code, notes, and snippets.

@dertajora
Last active January 27, 2018 06:46
Show Gist options
  • Save dertajora/d9741c7ca002623af5efa21a3a16b34b to your computer and use it in GitHub Desktop.
Save dertajora/d9741c7ca002623af5efa21a3a16b34b to your computer and use it in GitHub Desktop.
Example of generated migration file when we want to modify a table
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AdjustTicketsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tickets', function (Blueprint $table) {
$table->timestamp('processed_at')->nullable()->comment("When ticket processed by scheduler");;
$table->timestamp('completed_at')->nullable()->comment("When ticket completed by scheduler");;
$table->integer('scheduled_by')->nullable()->comment("Scheduler who schedule the ticket");;
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tickets', function (Blueprint $table) {
$table->dropColumn(['processed_at', 'completed_at', 'scheduled_by']);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment