Paragonik/paragonik-backend/database/migrations/2019_12_01_183308_create_re...

40 lines
1.1 KiB
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateReceiptItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('receipt_items', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->decimal('price', 8, 2);
$table->bigInteger('quantity');
$table->bigInteger('receipt_id')->unsigned();
$table->bigInteger('category_id')->unsigned();
$table->timestamps();
$table->foreign('receipt_id')->references('id')->on('receipts')->onDelete('cascade');
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->engine = 'InnoDB';
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('receipt_items');
}
}