<?php

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

class CreateArbeitsplatzsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('arbeitsplaetze', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();

            $table->string('name',50);
        });

        Schema::table('einteilungen', function (Blueprint $table) {

            $table->integer('arbeitsplatz_id')->unsigned();
            $table->foreign('arbeitsplatz_id')->references('id')->on('arbeitsplaetze');
        });
    }

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

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