<?php

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

class CreateVersionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('versions', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('learning_product_id');
            $table->string('version_number')->nullable();
            $table->dateTime('release_start', 0)->nullable();
            $table->dateTime('release_end', 0)->nullable();
            $table->dateTime('release_planning_date', 0)->nullable();
            $table->longText('release_planning_description')->nullable();
            $table->longText('technical_information')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::table('versions', function (Blueprint $table) {
            $table->foreign('learning_product_id')->references('id')->on('learning_products');
        });
    }

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

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