Skip to content

Instantly share code, notes, and snippets.

@weotch
Forked from mattaebersold/gist:bd9011f0d830e29dddb3
Last active August 29, 2015 14:24
Show Gist options
  • Save weotch/d564670de3d2edd866dd to your computer and use it in GitHub Desktop.
Save weotch/d564670de3d2edd866dd to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ProductImagesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
Schema::create('product_images', function($t){
$t->increments('id');
$t->integer('product_id')->unsigned();
$t->string('title');
$t->string('image')->nullable();
$t->string('image_crops')->nullable();
$t->integer('position');
$t->boolean('visible')->nullable()->index();
$t->timestamps();
$t->index(['position', 'created_at']);
$t->foreign('product_id')->references('id')->on('products')->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('product_images');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment