for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductVariantsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
Schema::create('product_variations', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('product_id');
$table->unsignedBigInteger('product_sku_id');
$table->unsignedBigInteger('product_attribute_id');
$table->unsignedBigInteger('product_attribute_value_id');
$table->foreign('product_id')
->references('id')
->on('products')
->onDelete('cascade');
$table->foreign('product_sku_id')
->on('product_skus')
$table->foreign('product_attribute_id')
->on('product_attributes')
$table->foreign('product_attribute_value_id')
->on('product_attribute_values')
$table->unique(['product_id', 'product_attribute_id', 'product_sku_id'], 'product_variation_sku');
// $table->unique(['product_id', 'product_attribute_id', 'product_attribute_value_id'], 'product_variation_attribute');
});
}
* Reverse the migrations.
public function down()
Schema::dropIfExists('product_variants');