Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Database migration for laravel for 'buyers' table

<?php

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

class CreateBuyersTable extends Migration


{
public function up()
{
Schema::create('buyers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->nullable();
$table->string('phone')->nullable();
$table->text('address')->nullable();
$table->unsignedBigInteger('country_id')->nullable();
$table->string('code')->nullable(); // Add code column
$table->string('logo')->nullable(); // Add logo column
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
$table->softDeletes();
$table->timestamps();

$table->foreign('country_id')->references('id')->on('countries')-
>onDelete('cascade');
});
}

public function down()


{
Schema::dropIfExists('buyers');
}
}

You might also like