Minor DB rework, remove spaces in database/migration files

This commit is contained in:
Deon George 2021-05-03 22:12:26 +10:00
parent 6f4c58f01f
commit bede0a5880
13 changed files with 433 additions and 252 deletions

View File

@ -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);
}
}

View 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);
}
}

View File

@ -6,31 +6,31 @@ use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View File

@ -6,27 +6,27 @@ use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View 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');
}
}

View File

@ -6,36 +6,44 @@ use Illuminate\Database\Migrations\Migration;
class CreateZones extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('zones', function (Blueprint $table) {
$table->integer('id')->primary();
$table->timestamps();
$table->binary('zt_id',10)->nullable();
$table->binary('ztnet',6)->nullable();
$table->ipAddress('ipv4')->nullable();
$table->integer('ipv4_mask')->nullable();
$table->ipAddress('ipv6')->nullable();
$table->integer('ipv6_mask')->nullable();
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('zones', function (Blueprint $table) {
$table->integer('id')->primary();
$table->timestamps();
$table->unique('zt_id');
$table->foreign('zt_id')->references('id')->on('zt');
});
$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();
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('zones');
}
$table->ipAddress('ipv6')->nullable();
$table->integer('ipv6_mask')->nullable();
$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');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('zones');
}
}

View File

@ -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']);

View File

@ -6,51 +6,51 @@ use Illuminate\Database\Migrations\Migration;
class CreateEchomail extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('echomails', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('pkt_from');
$table->integer('pkt_to');
$table->datetime('pkt_date');
$table->string('pkt');
$table->string('flags');
$table->integer('cost');
$table->string('from_user');
$table->integer('from_ftn');
$table->string('to_user');
$table->string('subject');
$table->datetime('date');
$table->string('tz')->nullable();
$table->string('area');
$table->string('msgid')->nullable();
$table->string('replyid')->nullable();
$table->text('message');
$table->string('origin');
$table->text('original')->nullable();
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('echomails', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('pkt_from');
$table->integer('pkt_to');
$table->datetime('pkt_date');
$table->string('pkt');
$table->string('flags');
$table->integer('cost');
$table->string('from_user');
$table->integer('from_ftn');
$table->string('to_user');
$table->string('subject');
$table->datetime('date');
$table->string('tz')->nullable();
$table->string('area');
$table->string('msgid')->nullable();
$table->string('replyid')->nullable();
$table->text('message');
$table->string('origin');
$table->text('original')->nullable();
$table->index('pkt_from');
$table->index('pkt_to');
$table->index('from_ftn');
$table->foreign('pkt_from')->references('id')->on('nodes');
$table->foreign('pkt_to')->references('id')->on('nodes');
$table->foreign('from_ftn')->references('id')->on('nodes');
});
}
$table->index('pkt_from');
$table->index('pkt_to');
$table->index('from_ftn');
$table->foreign('pkt_from')->references('id')->on('nodes');
$table->foreign('pkt_to')->references('id')->on('nodes');
$table->foreign('from_ftn')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('echomails');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('echomails');
}
}

View File

@ -6,57 +6,57 @@ use Illuminate\Database\Migrations\Migration;
class CreateEchomailTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('echomail_kludge', function (Blueprint $table) {
$table->integer('echomail_id');
$table->string('kludge_id')->nullable();
$table->json('value');
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('echomail_kludge', function (Blueprint $table) {
$table->integer('echomail_id');
$table->string('kludge_id')->nullable();
$table->json('value');
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
});
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
});
Schema::create('echomail_seenby', function (Blueprint $table) {
$table->integer('echomail_id');
$table->integer('node_id');
Schema::create('echomail_seenby', function (Blueprint $table) {
$table->integer('echomail_id');
$table->integer('node_id');
$table->unique(['echomail_id','node_id']);
$table->unique(['echomail_id','node_id']);
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
Schema::create('echomail_path', function (Blueprint $table) {
$table->integer('echomail_id');
$table->integer('node_id');
$table->integer('sequence');
Schema::create('echomail_path', function (Blueprint $table) {
$table->integer('echomail_id');
$table->integer('node_id');
$table->integer('sequence');
$table->unique(['echomail_id','sequence']);
$table->unique(['echomail_id','sequence']);
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
$table->index('echomail_id');
$table->foreign('echomail_id')->references('id')->on('echomails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('echomail_path');
Schema::dropIfExists('echomail_seenby');
Schema::dropIfExists('echomail_kludge');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('echomail_path');
Schema::dropIfExists('echomail_seenby');
Schema::dropIfExists('echomail_kludge');
}
}

View File

@ -6,55 +6,55 @@ use Illuminate\Database\Migrations\Migration;
class CreateNetmail extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('netmails', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('netmails', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('pkt_from');
$table->integer('pkt_to');
$table->datetime('pkt_date');
$table->string('pkt');
$table->integer('pkt_from');
$table->integer('pkt_to');
$table->datetime('pkt_date');
$table->string('pkt');
$table->string('flags');
$table->integer('cost');
$table->string('from_user');
$table->integer('from_ftn');
$table->string('to_user');
$table->integer('to_ftn');
$table->string('subject');
$table->datetime('date');
$table->string('tz')->nullable();
$table->string('msgid')->nullable();
$table->string('replyid')->nullable();
$table->text('message');
$table->string('origin');
$table->text('original')->nullable();
$table->string('flags');
$table->integer('cost');
$table->string('from_user');
$table->integer('from_ftn');
$table->string('to_user');
$table->integer('to_ftn');
$table->string('subject');
$table->datetime('date');
$table->string('tz')->nullable();
$table->string('msgid')->nullable();
$table->string('replyid')->nullable();
$table->text('message');
$table->string('origin');
$table->text('original')->nullable();
$table->index('pkt_from');
$table->index('pkt_to');
$table->index('from_ftn');
$table->index('to_ftn');
$table->foreign('pkt_from')->references('id')->on('nodes');
$table->foreign('pkt_to')->references('id')->on('nodes');
$table->foreign('from_ftn')->references('id')->on('nodes');
$table->foreign('to_ftn')->references('id')->on('nodes');
});
}
$table->index('pkt_from');
$table->index('pkt_to');
$table->index('from_ftn');
$table->index('to_ftn');
$table->foreign('pkt_from')->references('id')->on('nodes');
$table->foreign('pkt_to')->references('id')->on('nodes');
$table->foreign('from_ftn')->references('id')->on('nodes');
$table->foreign('to_ftn')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('netmails');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('netmails');
}
}

View File

@ -6,45 +6,45 @@ use Illuminate\Database\Migrations\Migration;
class CreateNetmailTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('kludge_netmail', function (Blueprint $table) {
$table->integer('netmail_id');
$table->string('kludge_id')->nullable();
$table->json('value');
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('kludge_netmail', function (Blueprint $table) {
$table->integer('netmail_id');
$table->string('kludge_id')->nullable();
$table->json('value');
$table->index('netmail_id');
$table->foreign('netmail_id')->references('id')->on('netmails');
});
$table->index('netmail_id');
$table->foreign('netmail_id')->references('id')->on('netmails');
});
Schema::create('netmail_path', function (Blueprint $table) {
$table->integer('netmail_id');
$table->integer('node_id');
$table->integer('sequence');
$table->json('value');
Schema::create('netmail_path', function (Blueprint $table) {
$table->integer('netmail_id');
$table->integer('node_id');
$table->integer('sequence');
$table->json('value');
$table->unique(['netmail_id','sequence']);
$table->unique(['netmail_id','sequence']);
$table->index('netmail_id');
$table->foreign('netmail_id')->references('id')->on('netmails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
$table->index('netmail_id');
$table->foreign('netmail_id')->references('id')->on('netmails');
$table->index('node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('netmail_path');
Schema::dropIfExists('kludge_netmail');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('netmail_path');
Schema::dropIfExists('kludge_netmail');
}
}

View 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');
}
}

View 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',
]);
}
}