<?php

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

class CreatePurchaseOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('purchase_orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('image_url');
            $table->double('amount');
            $table->integer('booking_id')->unsigned()->nullable;
            $table->foreign('booking_id')->references('id')->on('bookings');
            $table->timestamps();
        });
    }

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