<?php

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

class CreateTableHostelRating extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::create('hostel_ratings', function(Blueprint $table) {

            $table->increments('id');
            $table->string('name')->nullable();
            $table->string('phone')->nullable();
            $table->float('rating')->default(0);
            $table->text('comment')->nullable();
            $table->timestamps();

        });

        Schema::table('hostels', function(Blueprint $table) {
            $table->integer('avg_ratings')->default(0);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::drop('hostel_ratings');

        Schema::table('hostels', function(Blueprint $table) {
            $table->dropColumn('avg_ratings');
        });
    }
}
