-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add database changes for Coterm & base controller
- Loading branch information
1 parent
e6cec05
commit f3e6356
Showing
6 changed files
with
144 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Convoy\Http\Controllers\Admin; | ||
|
||
use Illuminate\Http\Request; | ||
|
||
class CotermController | ||
{ | ||
public function index() | ||
{ | ||
|
||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
|
||
} | ||
|
||
public function show($id) | ||
{ | ||
} | ||
|
||
public function update(Request $request, $id) | ||
{ | ||
} | ||
|
||
public function destroy($id) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Convoy\Models; | ||
|
||
use Convoy\Casts\NullableEncrypter; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\HasMany; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
|
||
class Coterm extends Model | ||
{ | ||
public const COTERM_TOKEN_ID_LENGTH = 16; | ||
public const COTERM_TOKEN_LENGTH = 64; | ||
|
||
protected $guarded = [ | ||
'id', | ||
'created_at', | ||
'updated_at', | ||
]; | ||
|
||
protected $hidden = [ | ||
'token_id', 'token', | ||
]; | ||
|
||
protected $casts = [ | ||
'is_tls_enabled' => 'boolean', | ||
'coterm_token' => NullableEncrypter::class, | ||
]; | ||
|
||
public static $validationRules = [ | ||
'is_tls_enabled' => 'required|boolean', | ||
'fqdn' => 'required|string|max:191', | ||
'port' => 'required|integer|min:1|max:65535', | ||
'token_id' => 'required|string|max:191', | ||
'token' => 'required|string|max:191', | ||
]; | ||
|
||
public function nodes(): HasMany | ||
{ | ||
return $this->hasMany(Node::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
database/migrations/2023_11_11_175741_create_coterms_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::create('coterms', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->boolean('is_tls_enabled'); | ||
$table->string('fqdn'); | ||
$table->integer('port'); | ||
$table->string('token_id'); | ||
$table->string('token'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('coterms'); | ||
} | ||
}; |
36 changes: 36 additions & 0 deletions
36
database/migrations/2023_11_11_181546_extract_coterm_from_nodes_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('nodes', function (Blueprint $table) { | ||
$table->dropUnique(['coterm_token_id']); | ||
$table->dropColumn( | ||
['coterm_enabled', 'coterm_tls_enabled', 'coterm_fqdn', 'coterm_port', 'coterm_token_id', 'coterm_token'], | ||
); | ||
|
||
$table->foreignId('coterm_id')->after('network')->nullable()->constrained()->nullOnDelete(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('nodes', function (Blueprint $table) { | ||
$table->after('network', function (Blueprint $table) { | ||
$table->boolean('coterm_enabled')->default(false); | ||
$table->boolean('coterm_tls_enabled')->default(true); | ||
$table->string('coterm_fqdn')->nullable(); | ||
$table->integer('coterm_port')->default(443); | ||
$table->string('coterm_token_id')->nullable()->unique(); | ||
$table->text('coterm_token')->nullable(); | ||
}); | ||
|
||
$table->dropForeign(['coterm_id']); | ||
$table->dropColumn('coterm_id'); | ||
}); | ||
} | ||
}; |