<?php

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

class CreateUserLevelMarginsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_level_margins', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('user_level_id');

            $table->decimal('price_from', 8, 2)->nullable();
            //$table->decimal('price_to', 8, 2)->nullable();

            $table->decimal('trading_margin', 5, 2)->nullable();
            $table->decimal('commission', 5, 2)->nullable();

            $table->timestamps();

            $table->foreign('user_level_id')
                ->references('id')
                ->on('user_levels')
                ->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_level_margins');
    }
}
