2022-10-23 02:46:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
|
|
|
class Addresses extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create('addresses', function (Blueprint $table) {
|
|
|
|
$table->id();
|
|
|
|
$table->timestamps();
|
|
|
|
$table->boolean('active');
|
|
|
|
$table->boolean('validated')->default(FALSE);
|
|
|
|
|
|
|
|
$table->bigInteger('zone_id');
|
|
|
|
$table->foreign('zone_id')->references('id')->on('zones');
|
|
|
|
|
|
|
|
$table->integer('region_id');
|
|
|
|
$table->integer('host_id');
|
|
|
|
$table->integer('node_id');
|
|
|
|
$table->integer('point_id');
|
|
|
|
$table->integer('status')->nullable(); // @note Used to record Down/Private/Pending, etc
|
|
|
|
|
|
|
|
$table->integer('role');
|
|
|
|
|
|
|
|
$table->bigInteger('system_id');
|
|
|
|
$table->foreign('system_id')->references('id')->on('systems');
|
|
|
|
|
|
|
|
$table->bigInteger('hub_id')->nullable();
|
|
|
|
$table->foreign('hub_id')->references('id')->on('addresses');
|
|
|
|
|
|
|
|
$table->softDeletes();
|
|
|
|
});
|
|
|
|
|
2022-11-19 11:15:08 +00:00
|
|
|
DB::statement("CREATE UNIQUE INDEX addresses_active ON addresses (zone_id,host_id,node_id,point_id) WHERE active = true");
|
2022-10-23 02:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('address_echomail');
|
|
|
|
Schema::dropIfExists('addresses');
|
|
|
|
}
|
|
|
|
}
|