api(application): v2 backport

This commit is contained in:
Matthew Penner 2022-12-14 17:05:46 -07:00
parent 4cd0bee231
commit 67bf3e342e
No known key found for this signature in database
172 changed files with 2922 additions and 1579 deletions

View file

@ -0,0 +1,31 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('admin_roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 64);
$table->string('description', 255)->nullable();
$table->integer('sort_id');
$table->json('permissions')->nullable();
$table->unique(['id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admin_roles');
}
};

View file

@ -0,0 +1,30 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->integer('admin_role_id')->nullable()->unsigned()->after('language');
$table->index('admin_role_id');
$table->foreign('admin_role_id')->references('id')->on('admin_roles')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['admin_role_id']);
$table->dropColumn('admin_role_id');
});
}
};

View file

@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('database_hosts', function (Blueprint $table) {
$table->dropForeign(['node_id']);
$table->dropColumn('node_id');
});
Schema::table('nodes', function (Blueprint $table) {
$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');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('nodes', function (Blueprint $table) {
$table->dropForeign(['database_host_id']);
$table->dropColumn('database_host_id');
});
Schema::table('database_hosts', function (Blueprint $table) {
$table->integer('node_id')->nullable()->unsigned()->after('max_databases');
$table->index('node_id')->nullable();
$table->foreign('node_id')->references('id')->on('nodes');
});
}
};

View file

@ -0,0 +1,58 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
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.
*/
public function down(): void
{
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();
});
}
};

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['name_first', 'name_last']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('name_first')->after('email')->nullable();
$table->string('name_last')->after('name_first')->nullable();
});
}
};

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('eggs', function (Blueprint $table) {
$table->dropColumn('config_logs');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('eggs', function (Blueprint $table) {
$table->text('config_logs')->nullable()->after('docker_image');
});
}
};

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('eggs', function (Blueprint $table) {
$table->string('script_container')->default('ghcr.io/pterodactyl/installers:alpine')->after('startup')->change();
$table->string('script_entry')->default('/bin/ash')->after('copy_script_from')->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('eggs', function (Blueprint $table) {
// You are stuck with the new values because I am too lazy to revert them :)
});
}
};

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class () extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->text('startup')->default(null)->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('servers', function (Blueprint $table) {
$table->text('startup')->change();
});
}
};