osb/database/migrations/0261-create_invoice_item.php

57 lines
1.5 KiB
PHP

<?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('invoice_items', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('start_at')->nullable();
$table->date('stop_at')->nullable();
$table->integer('module_id')->nullable();
$table->bigInteger('module_ref')->nullable();
$table->float('quantity', 10, 0)->nullable();
$table->integer('item_type')->nullable();
$table->string('product_name', 128)->nullable();
$table->float('discount_amt', 10, 0)->nullable();
$table->float('price_base', 10, 0)->nullable();
$table->integer('recur_schedule')->nullable();
$table->integer('invoice_id')->unsigned();
$table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices');
$table->integer('product_id')->unsigned()->nullable();
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
$table->integer('service_id')->unsigned()->nullable();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('invoice_items');
}
};