madbob/GASdottoNG

View on GitHub
code/database/migrations/2015_11_21_011239_create_variants_table.php

Summary

Maintainability
A
1 hr
Test Coverage
<?php

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

class CreateVariantsTable extends Migration
{
    public function up()
    {
        Schema::create('variants', function (Blueprint $table) {
            $table->string('id')->primary();
            $table->timestamps();

            $table->string('product_id');
            $table->string('name');

            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        });
    }

    public function down()
    {
        Schema::drop('variants');
    }
}