Refactor the database, in preparation to moving to postgresql
This commit is contained in:
57
database/migrations/2022_10_22_001259_addresses.php
Normal file
57
database/migrations/2022_10_22_001259_addresses.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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();
|
||||
});
|
||||
|
||||
DB::statement("CREATE UNIQUE INDEX active_addresses ON addresses (zone_id,region_id,host_id,node_id,point_id) WHERE active = true");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('address_echomail');
|
||||
Schema::dropIfExists('addresses');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user