Minor DB rework, remove spaces in database/migration files
This commit is contained in:
parent
6f4c58f01f
commit
bede0a5880
@ -4,7 +4,19 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Traits\ScopeActive;
|
||||
|
||||
class Zone extends Model
|
||||
{
|
||||
protected $fillable = ['id'];
|
||||
use ScopeActive;
|
||||
|
||||
/* SCOPES */
|
||||
|
||||
/**
|
||||
* Only query active records
|
||||
*/
|
||||
public function scopePublic()
|
||||
{
|
||||
return $this->where('public',TRUE);
|
||||
}
|
||||
}
|
17
app/Traits/ScopeActive.php
Normal file
17
app/Traits/ScopeActive.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add a ScopeActive to an Eloquent Model
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
trait ScopeActive
|
||||
{
|
||||
/**
|
||||
* Only query active records
|
||||
*/
|
||||
public function scopeActive()
|
||||
{
|
||||
return $this->where('active',TRUE);
|
||||
}
|
||||
}
|
33
database/migrations/2019_04_16_090345_create_domains.php
Normal file
33
database/migrations/2019_04_16_090345_create_domains.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateDomains extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('domains', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('name',8)->unique();
|
||||
$table->string('dnsdomain')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('domains');
|
||||
}
|
||||
}
|
@ -16,14 +16,22 @@ class CreateZones extends Migration
|
||||
Schema::create('zones', function (Blueprint $table) {
|
||||
$table->integer('id')->primary();
|
||||
$table->timestamps();
|
||||
$table->binary('zt_id',10)->nullable();
|
||||
$table->binary('ztnet',6)->nullable();
|
||||
|
||||
$table->integer('zone_id');
|
||||
$table->string('description')->nullable();
|
||||
$table->boolean('active')->default(TRUE);
|
||||
$table->boolean('public')->default(TRUE);
|
||||
|
||||
$table->ipAddress('ipv4')->nullable();
|
||||
$table->integer('ipv4_mask')->nullable();
|
||||
|
||||
$table->ipAddress('ipv6')->nullable();
|
||||
$table->integer('ipv6_mask')->nullable();
|
||||
|
||||
$table->unique('zt_id');
|
||||
$table->integer('domain_id')->nullable()->unique();
|
||||
$table->foreign('domain_id')->references('id')->on('domains');
|
||||
|
||||
$table->binary('zt_id',10)->nullable()->unique();
|
||||
$table->foreign('zt_id')->references('id')->on('zt');
|
||||
});
|
||||
|
||||
|
@ -28,8 +28,9 @@ class CreateNodes extends Migration
|
||||
$table->string('system');
|
||||
$table->string('sysop');
|
||||
$table->string('location');
|
||||
$table->integer('baud');
|
||||
$table->integer('baud')->default('0');
|
||||
$table->string('phone')->nullable();
|
||||
|
||||
$table->binary('zt',10)->nullable();
|
||||
|
||||
$table->unique(['zone_id','host_id','node_id','point_id']);
|
||||
|
41
database/migrations/2021_05_03_104554_create_setup.php
Normal file
41
database/migrations/2021_05_03_104554_create_setup.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSetup extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('setups', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
|
||||
$table->integer('opt_md');
|
||||
});
|
||||
|
||||
Schema::create('node_setup', function (Blueprint $table) {
|
||||
$table->integer('node_id');
|
||||
$table->foreign('node_id')->references('id')->on('nodes');
|
||||
$table->integer('setup_id');
|
||||
$table->foreign('setup_id')->references('id')->on('setups');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('node_setup');
|
||||
Schema::dropIfExists('setups');
|
||||
}
|
||||
}
|
69
database/seeds/InitialSetupSeeder.php
Normal file
69
database/seeds/InitialSetupSeeder.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InitialSetupSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('protocols')->insert([
|
||||
'name'=>'BINKP',
|
||||
'port'=>24554,
|
||||
'active'=>TRUE,
|
||||
]);
|
||||
DB::table('protocols')->insert([
|
||||
'name'=>'EMSI',
|
||||
'port'=>60179,
|
||||
'active'=>TRUE,
|
||||
]);
|
||||
DB::table('software')->insert([
|
||||
'name'=>'Custom',
|
||||
'active'=>TRUE,
|
||||
]);
|
||||
|
||||
DB::table('domains')->insert([
|
||||
'name' => 'private',
|
||||
]);
|
||||
|
||||
DB::table('zones')->insert([
|
||||
'zone_id'=>'10',
|
||||
'domain_id'=>1,
|
||||
'public'=>TRUE,
|
||||
'active'=>TRUE,
|
||||
'name'=>'private',
|
||||
'description'=>'PrivateNet: Internal Testing Network'
|
||||
]);
|
||||
|
||||
DB::table('nodes')->insert([
|
||||
'zone_id'=>'1',
|
||||
'host_id'=>'999',
|
||||
'node_id'=>'999',
|
||||
'is_host'=>TRUE,
|
||||
'active'=>TRUE,
|
||||
'system'=>'FTN Clearing House Dev',
|
||||
'sysop'=>'Deon George',
|
||||
'location'=>'Parkdale, AUS',
|
||||
'email'=>'deon@leenooks.net',
|
||||
'address'=>'fidohub.leenooks.net',
|
||||
'port'=>24554,
|
||||
'protocol_id'=>1,
|
||||
'software_id'=>1,
|
||||
]);
|
||||
|
||||
DB::table('setups')->insert([
|
||||
'opt_md'=>'1',
|
||||
]);
|
||||
|
||||
DB::table('setup')->insert([
|
||||
'node_id' => '1',
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user