<?php

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

class CreateBookingsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('bookings', function (Blueprint $table) {
            $table->increments('id');
            $table->string('account_name');
            $table->integer('account_num'); 
            $table->string('bank_name');
            $table->string('bank_branch');
            $table->string('company_name');
            $table->string('company_address');
            $table->string('bank_address');
            $table->string('swift_code');
            $table->string('cnap');
            $table->string('term');
            $table->double('amount');
            $table->unsignedInteger('rate_id');
            $table->foreign('rate_id')
                    ->references('id')->on('rates')
                    ->onDelete('cascade');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {   
        Schema::table('bookings', function(Blueprint $table)
        {
            $table->dropForeign('bookings_rate_id_foreign');
            $table->dropColumn('rate_id');
        });

        Schema::dropIfExists('bookings');
        
    }
}
