laravel-api / database / migrations / 2022_10_26_175138_create_items_table.php
2022_10_26_175138_create_items_table.php
Raw
<?php

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

class CreateItemsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('items', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->string('name');
            $table->bigInteger('category_id')->unsigned(); 
            $table->foreign('category_id')->references('id')->on('categories');
            $table->float('price');
            $table->longText('description');
            $table->string('image');
            $table->integer('amount');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('items');
    }
}