nodes: rename port columns, add public_ port columns

This commit is contained in:
Matthew Penner 2021-02-11 10:21:32 -07:00
parent b7ee2195d7
commit 5f56ff0fed
9 changed files with 116 additions and 45 deletions

View file

@ -27,6 +27,10 @@ class NodeFactory extends Factory
'public' => true,
'name' => $this->faker->firstName,
'fqdn' => $this->faker->ipv4,
'listen_port_http' => 8080,
'listen_port_sftp' => 2022,
'public_port_http' => 8080,
'public_port_sftp' => 2022,
'scheme' => 'http',
'behind_proxy' => false,
'memory' => 1024,
@ -36,9 +40,7 @@ class NodeFactory extends Factory
'upload_size' => 100,
'daemon_token_id' => Str::random(Node::DAEMON_TOKEN_ID_LENGTH),
'daemon_token' => Crypt::encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)),
'daemonListen' => 8080,
'daemonSFTP' => 2022,
'daemonBase' => '/var/lib/pterodactyl/volumes',
'daemon_base' => '/var/lib/pterodactyl/volumes',
];
}
}

View file

@ -23,7 +23,7 @@ class AddNodes extends Migration
$table->mediumInteger('disk_overallocate')->unsigned()->nullable();
$table->char('daemonSecret', 36)->unique();
$table->smallInteger('daemonListen')->unsigned()->default(8080);
$table->smallInteger('daemonSFTP')->unsgined()->default(2022);
$table->smallInteger('daemonSFTP')->unsigned()->default(2022);
$table->string('daemonBase')->default('/home/daemon-files');
$table->timestamps();
});

View file

@ -19,7 +19,7 @@ class AddDatabaseHostIdColumnToNodesTable extends Migration
});
Schema::table('nodes', function (Blueprint $table) {
$table->integer('database_host_id')->nullable()->unsigned()->after('daemonBase');
$table->integer('database_host_id')->nullable()->unsigned()->after('location_id');
$table->index('database_host_id')->nullable();
$table->foreign('database_host_id')->references('id')->on('database_hosts')->onDelete('set null');
});

View file

@ -0,0 +1,63 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangePortColumnsOnNodesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('nodes', function (Blueprint $table) {
$table->renameColumn('daemonListen', 'listen_port_http');
$table->renameColumn('daemonSFTP', 'listen_port_sftp');
$table->renameColumn('daemonBase', 'daemon_base');
});
Schema::table('nodes', function (Blueprint $table) {
$table->integer('listen_port_http')->unsigned()->default(8080)->after('fqdn')->change();
$table->integer('listen_port_sftp')->unsigned()->default(2022)->after('listen_port_sftp')->change();
$table->integer('public_port_http')->unsigned()->default(8080)->after('listen_port_http');
$table->integer('public_port_sftp')->unsigned()->default(2022)->after('listen_port_sftp');
});
DB::transaction(function () {
foreach (DB::select('SELECT id, listen_port_http, listen_port_sftp FROM nodes') as $datum) {
DB::update('UPDATE nodes SET public_port_http = ?, public_port_sftp = ? WHERE id = ?', [
$datum->listen_port_http,
$datum->listen_port_sftp,
$datum->id,
]);
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('nodes', function (Blueprint $table) {
$table->renameColumn('listen_port_http', 'daemonListen');
$table->renameColumn('listen_port_sftp', 'daemonSFTP');
$table->renameColumn('daemon_base', 'daemonBase');
$table->dropColumn('public_port_http');
$table->dropColumn('public_port_sftp');
});
Schema::table('nodes', function (Blueprint $table) {
$table->smallInteger('daemonListen')->unsigned()->default(8080)->after('daemon_token')->change();
$table->smallInteger('daemonSFTP')->unsigned()->default(2022)->after('daemonListen')->change();
});
}
}