Move DomainController::NODE* to Address::NODE*, make role mandatory in the database, change logic so that mail generated by the host comes from a node address.

This commit is contained in:
Deon George
2022-01-24 22:56:13 +11:00
parent efa7195633
commit d660d5a6df
15 changed files with 143 additions and 110 deletions

View File

@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddressRoleNotnull extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
\App\Models\Address::whereNull('role')->withTrashed()->update(['role'=>\App\Models\Address::NODE_ACTIVE]);
DB::commit();
DB::statement("ALTER TABLE addresses ALTER COLUMN role set NOT NULL");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::statement("ALTER TABLE addresses ALTER COLUMN role drop NOT NULL");
}
}

View File

@@ -6,7 +6,6 @@ use Carbon\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\DomainController;
use App\Models\{Address,Domain,System,Zone};
class NodeHierarchy extends Seeder
@@ -73,7 +72,7 @@ class NodeHierarchy extends Seeder
'node_id'=>0,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>DomainController::NODE_ZC,
'role'=>Address::NODE_ZC,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -90,6 +89,7 @@ class NodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -107,7 +107,7 @@ class NodeHierarchy extends Seeder
'node_id'=>0,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>DomainController::NODE_RC,
'role'=>Address::NODE_RC,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -124,6 +124,7 @@ class NodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -142,7 +143,7 @@ class NodeHierarchy extends Seeder
'node_id'=>0,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>DomainController::NODE_NC,
'role'=>Address::NODE_NC,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -159,6 +160,7 @@ class NodeHierarchy extends Seeder
'node_id'=>$nid,
'point_id'=>0,
'system_id'=>$so->id,
'role'=>Address::NODE_ACTIVE,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);
@@ -175,7 +177,7 @@ class NodeHierarchy extends Seeder
$hub->node_id = $bid;
$hub->point_id = 0;
$hub->system_id = $so->id;
$hub->role = DomainController::NODE_HC;
$hub->role = Address::NODE_HC;
$hub->created_at = Carbon::now();
$hub->updated_at = Carbon::now();
$hub->save();
@@ -194,6 +196,7 @@ class NodeHierarchy extends Seeder
'point_id'=>0,
'system_id'=>$so->id,
'hub_id'=>$hub->id,
'role'=>Address::NODE_ACTIVE,
'created_at'=>Carbon::now(),
'updated_at'=>Carbon::now(),
]);