File: /home/imensosw/www/amanda/database/migrations/2020_12_12_060346_add_user_id_in_orders.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUserIdInOrders extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('orders', function (Blueprint $table) {
$table->bigInteger('user_id')->unsigned()->nullable()->after('id');
$table->string('address')->nullable();
$table->boolean('is_delivered')->default(false);
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn('address');
$table->dropColumn('is_delivered');
$table->dropColumn('user_id');
});
}
}