MIELICIUS / database / migrations / 2023_01_08_080104_create_bomsementaras_table.php
2023_01_08_080104_create_bomsementaras_table.php
Raw
<?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('bomsementaras', function (Blueprint $table) {
            $table->id('idbomsementara');
            $table->bigInteger('idbomnya')->unsigned();
            $table->string('kodebah');
            $table->float('banyakqty');
            $table->bigInteger('hargaakhir');
            $table->timestamps();
        });
        Schema::table('bomsementaras', function (Blueprint $table) {
            $table->foreign('idbomnya')->references('idbom')->on('boms')->onUpdate('cascade')->onDelete('cascade');
        });
        Schema::table('bomsementaras', function (Blueprint $table) {
            $table->foreign('kodebah')->references('kodebahan')->on('bahans')->onUpdate('cascade')->onDelete('cascade');
        });
    }

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