osb/database/migrations/0224-create_phone.php

111 lines
3.2 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('supplier_phone',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('product_id',16);
$table->string('product_desc',128)->nullable();
$table->float('base_cost');
$table->float('setup_cost')->nullable();
$table->integer('contract_term')->unsigned()->nullable();
$table->string('technology')->nullable();
$table->integer('supplier_detail_id')->unsigned();
$table->foreign(['supplier_detail_id','site_id'])->references(['id','site_id'])->on('supplier_details');
$table->unique(['id','site_id']);
});
Schema::create('product_phone',function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->string('name',64);
$table->integer('contract_term')->unsigned()->nullable();
$table->string('technology')->nullable();
$table->integer('supplier_item_id')->unsigned();
$table->foreign(['supplier_item_id','site_id'])->references(['id','site_id'])->on('supplier_phone');
$table->unique(['id','site_id']);
});
Schema::create('service_phone', function(Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->string('service_number',10)->nullable();
$table->string('service_address',128)->nullable();
$table->string('service_username',128)->nullable();
$table->string('service_password',32)->nullable();
$table->string('technology')->nullable();
$table->date('connect_at')->nullable();
$table->date('expire_at')->nullable();
$table->integer('service_id')->unsigned();
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
$table->unique(['id','site_id']);
});
Schema::create('cost_phone', function (Blueprint $table)
{
$table->id();
$table->timestamps();
$table->integer('site_id')->unsigned();
$table->boolean('active')->default(false);
$table->date('start_at')->nullable();
$table->date('end_at')->nullable();
$table->float('base')->nullable();
$table->float('excess')->nullable();
$table->string('reference')->nullable();
$table->text('notes')->nullable();
$table->integer('cost_id')->unsigned();
$table->foreign(['cost_id','site_id'])->references(['id','site_id'])->on('costs');
$table->integer('service_phone_id')->unsigned()->nullable();
$table->foreign(['service_phone_id','site_id'])->references(['id','site_id'])->on('service_phone');
$table->integer('supplier_phone_id')->unsigned()->nullable();
$table->foreign(['supplier_phone_id','site_id'])->references(['id','site_id'])->on('supplier_phone');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('cost_phone');
Schema::dropIfExists('service_phone');
Schema::dropIfExists('product_phone');
Schema::dropIfExists('supplier_phone');
}
};