<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('operate_stock_logs', function (Blueprint $table) {
            $table->id();
            $table->integer('food_id')->comment("食品或营养素id");
            $table->integer('user_id')->comment("操作人id");
            $table->tinyInteger('type')->default(0)->comment("操作类型 0:后台 ,1:前端");
            $table->integer('before_num')->comment("修改之前数量");
            $table->integer('num')->comment("修改数量,负数则减,正数则加");
            $table->integer('after_num')->comment("修改之后数量");
            $table->integer('order_id')->nullable()->comment("订单id,如果有");
            $table->string('remark')->nullable()->comment("操作备注信息");
            $table->timestamps();
        });
    }

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