Merge branch 'develop' into dane/restore-backups

This commit is contained in:
Dane Everitt 2021-01-25 19:16:40 -08:00
commit 663143de0b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
575 changed files with 6080 additions and 6864 deletions

View file

@ -0,0 +1,27 @@
<?php
namespace Database\Factories;
use Pterodactyl\Models\Allocation;
use Illuminate\Database\Eloquent\Factories\Factory;
class AllocationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Allocation::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'ip' => $this->faker->ipv4,
'port' => $this->faker->randomNumber(5),
];
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Support\Str;
use Pterodactyl\Models\ApiKey;
use Illuminate\Database\Eloquent\Factories\Factory;
class ApiKeyFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = ApiKey::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
static $token;
return [
'key_type' => ApiKey::TYPE_APPLICATION,
'identifier' => Str::random(\Pterodactyl\Models\ApiKey::IDENTIFIER_LENGTH),
'token' => $token ?: $token = encrypt(Str::random(\Pterodactyl\Models\ApiKey::KEY_LENGTH)),
'allowed_ips' => null,
'memo' => 'Test Function Key',
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Backup;
use Illuminate\Database\Eloquent\Factories\Factory;
class BackupFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Backup::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'uuid' => Uuid::uuid4()->toString(),
'is_successful' => true,
'name' => $this->faker->sentence,
'disk' => Backup::ADAPTER_WINGS,
];
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Illuminate\Support\Str;
use Pterodactyl\Models\Database;
use Illuminate\Database\Eloquent\Factories\Factory;
class DatabaseFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Database::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
static $password;
return [
'database' => Str::random(10),
'username' => Str::random(10),
'remote' => '%',
'password' => $password ?: encrypt('test123'),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
}

View file

@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Eloquent\Factories\Factory;
class DatabaseHostFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = DatabaseHost::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'name' => $this->faker->colorName,
'host' => $this->faker->unique()->ipv4,
'port' => 3306,
'username' => $this->faker->colorName,
'password' => Crypt::encrypt($this->faker->word),
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Egg;
use Illuminate\Database\Eloquent\Factories\Factory;
class EggFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Egg::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'uuid' => Uuid::uuid4()->toString(),
'name' => $this->faker->name,
'description' => implode(' ', $this->faker->sentences()),
'startup' => 'java -jar test.jar',
];
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace Database\Factories;
use Illuminate\Support\Str;
use Pterodactyl\Models\EggVariable;
use Illuminate\Database\Eloquent\Factories\Factory;
class EggVariableFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = EggVariable::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'name' => $this->faker->firstName,
'description' => $this->faker->sentence(),
'env_variable' => Str::upper(Str::replaceArray(' ', ['_'], $this->faker->words(2, true))),
'default_value' => $this->faker->colorName,
'user_viewable' => 0,
'user_editable' => 0,
'rules' => 'required|string',
];
}
/**
* Indicate that the egg variable is viewable.
*/
public function viewable(): Factory
{
return $this->state(function (array $attributes) {
return [
'user_viewable' => 1,
];
});
}
/**
* Indicate that the egg variable is editable.
*/
public function editable(): Factory
{
return $this->state(function (array $attributes) {
return [
'user_editable' => 1,
];
});
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use Illuminate\Support\Str;
use Pterodactyl\Models\Location;
use Illuminate\Database\Eloquent\Factories\Factory;
class LocationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Location::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'short' => Str::random(8),
'long' => Str::random(32),
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Eloquent\Factories\Factory;
class NestFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Nest::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'uuid' => Uuid::uuid4()->toString(),
'author' => 'testauthor@example.com',
'name' => $this->faker->word,
'description' => null,
];
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use Pterodactyl\Models\Node;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Database\Eloquent\Factories\Factory;
class NodeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Node::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'uuid' => Uuid::uuid4()->toString(),
'public' => true,
'name' => $this->faker->firstName,
'fqdn' => $this->faker->ipv4,
'scheme' => 'http',
'behind_proxy' => false,
'memory' => 1024,
'memory_overallocate' => 0,
'disk' => 10240,
'disk_overallocate' => 0,
'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',
];
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use Pterodactyl\Models\Schedule;
use Illuminate\Database\Eloquent\Factories\Factory;
class ScheduleFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Schedule::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'name' => $this->faker->firstName(),
];
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use Pterodactyl\Models\Server;
use Illuminate\Database\Eloquent\Factories\Factory;
class ServerFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Server::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'uuid' => Uuid::uuid4()->toString(),
'uuidShort' => Str::lower(Str::random(8)),
'name' => $this->faker->firstName,
'description' => implode(' ', $this->faker->sentences()),
'skip_scripts' => 0,
'suspended' => 0,
'memory' => 512,
'swap' => 0,
'disk' => 512,
'io' => 500,
'cpu' => 0,
'threads' => null,
'oom_disabled' => 0,
'installed' => 1,
'allocation_limit' => null,
'database_limit' => null,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use Pterodactyl\Models\Subuser;
use Pterodactyl\Models\Permission;
use Illuminate\Database\Eloquent\Factories\Factory;
class SubuserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Subuser::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'permissions' => [
Permission::ACTION_WEBSOCKET_CONNECT,
],
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use Pterodactyl\Models\Task;
use Illuminate\Database\Eloquent\Factories\Factory;
class TaskFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Task::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
return [
'sequence_id' => $this->faker->randomNumber(1),
'action' => 'command',
'payload' => 'test command',
'time_offset' => 120,
'is_queued' => false,
];
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace Database\Factories;
use Carbon\Carbon;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
static $password;
return [
'external_id' => $this->faker->unique()->isbn10,
'uuid' => Uuid::uuid4()->toString(),
'username' => $this->faker->userName,
'email' => $this->faker->safeEmail,
'name_first' => $this->faker->firstName,
'name_last' => $this->faker->lastName,
'password' => $password ?: $password = bcrypt('password'),
'language' => 'en',
'root_admin' => false,
'use_totp' => false,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
/**
* Indicate that the user is an admin.
*/
public function admin(): Factory
{
return $this->state(function (array $attributes) {
return [
'root_admin' => true,
];
});
}
}

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use Pterodactyl\Models\Nest;
use Illuminate\Database\Seeder;
use Illuminate\Http\UploadedFile;
@ -40,12 +42,6 @@ class EggSeeder extends Seeder
/**
* EggSeeder constructor.
*
* @param \Pterodactyl\Services\Eggs\Sharing\EggImporterService $importerService
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Eggs\Sharing\EggUpdateImporterService $updateImporterService
* @param \Illuminate\Filesystem\Filesystem $filesystem
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
*/
public function __construct(
EggImporterService $importerService,
@ -73,8 +69,6 @@ class EggSeeder extends Seeder
/**
* Return a list of eggs to import.
*
* @return \Illuminate\Support\Collection
*/
protected function getEggsToImport(): Collection
{
@ -89,9 +83,6 @@ class EggSeeder extends Seeder
/**
* Find the nest that these eggs should be attached to.
*
* @param string $nestName
* @return \Pterodactyl\Models\Nest
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
private function findMatchingNest(string $nestName): Nest
@ -104,12 +95,10 @@ class EggSeeder extends Seeder
/**
* Loop through the list of egg files and import them.
*
* @param \Pterodactyl\Models\Nest $nest
*/
private function parseEggFiles(Nest $nest)
{
$files = $this->filesystem->allFiles(database_path('seeds/eggs/' . kebab_case($nest->name)));
$files = $this->filesystem->allFiles(database_path('Seeders/eggs/' . kebab_case($nest->name)));
$this->command->alert('Updating Eggs for Nest: ' . $nest->name);
Collection::make($files)->each(function ($file) use ($nest) {

View file

@ -1,5 +1,7 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Pterodactyl\Services\Nests\NestCreationService;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
@ -18,9 +20,6 @@ class NestSeeder extends Seeder
/**
* NestSeeder constructor.
*
* @param \Pterodactyl\Services\Nests\NestCreationService $creationService
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
*/
public function __construct(
NestCreationService $creationService,
@ -50,8 +49,6 @@ class NestSeeder extends Seeder
/**
* Create the Minecraft nest to be used later on.
*
* @param array|null $nest
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createMinecraftNest(array $nest = null)
@ -67,8 +64,6 @@ class NestSeeder extends Seeder
/**
* Create the Source Engine Games nest to be used later on.
*
* @param array|null $nest
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createSourceEngineNest(array $nest = null)
@ -84,8 +79,6 @@ class NestSeeder extends Seeder
/**
* Create the Voice Servers nest to be used later on.
*
* @param array|null $nest
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createVoiceServersNest(array $nest = null)
@ -101,8 +94,6 @@ class NestSeeder extends Seeder
/**
* Create the Rust nest to be used later on.
*
* @param array|null $nest
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
private function createRustNest(array $nest = null)

View file

@ -1,14 +1,18 @@
{
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
"meta": {
"version": "PTDL_v1"
"version": "PTDL_v1",
"update_url": null
},
"exported_at": "2020-10-25T22:24:15+00:00",
"exported_at": "2021-01-12T15:44:41+01:00",
"name": "Teamspeak3 Server",
"author": "support@pterodactyl.io",
"description": "VoIP software designed with security in mind, featuring crystal clear voice quality, endless customization options, and scalabilty up to thousands of simultaneous users.",
"image": "quay.io\/parkervcp\/pterodactyl-images:base_debian",
"startup": ".\/ts3server default_voice_port={{SERVER_PORT}} query_port={{SERVER_PORT}} filetransfer_ip=0.0.0.0 filetransfer_port={{FILE_TRANSFER}} license_accepted=1",
"features": null,
"images": [
"quay.io\/parkervcp\/pterodactyl-images:base_debian"
],
"startup": ".\/ts3server default_voice_port={{SERVER_PORT}} query_port={{QUERY_PORT}} filetransfer_ip=0.0.0.0 filetransfer_port={{FILE_TRANSFER}} license_accepted=1",
"config": {
"files": "{}",
"startup": "{\r\n \"done\": \"listening on 0.0.0.0:\",\r\n \"userInteraction\": []\r\n}",
@ -40,6 +44,15 @@
"user_viewable": true,
"user_editable": false,
"rules": "required|integer|between:1,65535"
},
{
"name": "Query Port",
"description": "The Teamspeak Query Port",
"env_variable": "QUERY_PORT",
"default_value": "10011",
"user_viewable": true,
"user_editable": false,
"rules": "required|integer|between:1,65535"
}
]
}

View file

@ -1,197 +0,0 @@
<?php
use Carbon\Carbon;
use Ramsey\Uuid\Uuid;
use Cake\Chronos\Chronos;
use Illuminate\Support\Str;
use Pterodactyl\Models\Node;
use Faker\Generator as Faker;
use Pterodactyl\Models\ApiKey;
/** @var \Illuminate\Database\Eloquent\Factory $factory */
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(Pterodactyl\Models\Server::class, function (Faker $faker) {
return [
'uuid' => Uuid::uuid4()->toString(),
'uuidShort' => str_random(8),
'name' => $faker->firstName,
'description' => implode(' ', $faker->sentences()),
'skip_scripts' => 0,
'status' => null,
'memory' => 512,
'swap' => 0,
'disk' => 512,
'io' => 500,
'cpu' => 0,
'oom_disabled' => 0,
'database_limit' => null,
'allocation_limit' => null,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
});
$factory->define(Pterodactyl\Models\User::class, function (Faker $faker) {
static $password;
return [
'external_id' => $faker->unique()->isbn10,
'uuid' => $faker->uuid,
'username' => $faker->userName,
'email' => $faker->safeEmail,
'name_first' => $faker->firstName,
'name_last' => $faker->lastName,
'password' => $password ?: $password = bcrypt('password'),
'language' => 'en',
'root_admin' => false,
'use_totp' => false,
'created_at' => Chronos::now(),
'updated_at' => Chronos::now(),
];
});
$factory->state(Pterodactyl\Models\User::class, 'admin', function () {
return [
'root_admin' => true,
];
});
$factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) {
return [
'short' => Str::random(8),
'long' => $faker->catchPhrase,
];
});
$factory->define(Pterodactyl\Models\Node::class, function (Faker $faker) {
return [
'uuid' => Uuid::uuid4()->toString(),
'public' => true,
'name' => $faker->firstName,
'fqdn' => $faker->ipv4,
'scheme' => 'http',
'behind_proxy' => false,
'memory' => 1024,
'memory_overallocate' => 0,
'disk' => 10240,
'disk_overallocate' => 0,
'upload_size' => 100,
'daemon_token_id' => Str::random(Node::DAEMON_TOKEN_ID_LENGTH),
'daemon_token' => encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH)),
'daemonListen' => 8080,
'daemonSFTP' => 2022,
'daemonBase' => '/var/lib/pterodactyl/volumes',
];
});
$factory->define(Pterodactyl\Models\Nest::class, function (Faker $faker) {
return [
'uuid' => $faker->unique()->uuid,
'author' => 'testauthor@example.com',
'name' => $faker->word,
'description' => null,
];
});
$factory->define(Pterodactyl\Models\Egg::class, function (Faker $faker) {
return [
'uuid' => $faker->unique()->uuid,
'name' => $faker->name,
'description' => implode(' ', $faker->sentences(3)),
'startup' => 'java -jar test.jar',
];
});
$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker $faker) {
return [
'name' => $faker->firstName,
'description' => $faker->sentence(),
'env_variable' => strtoupper(str_replace(' ', '_', $faker->words(2, true))),
'default_value' => $faker->colorName,
'user_viewable' => 0,
'user_editable' => 0,
'rules' => 'required|string',
];
});
$factory->state(Pterodactyl\Models\EggVariable::class, 'viewable', function () {
return ['user_viewable' => 1];
});
$factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () {
return ['user_editable' => 1];
});
$factory->define(Pterodactyl\Models\Subuser::class, function (Faker $faker) {
return [];
});
$factory->define(Pterodactyl\Models\Allocation::class, function (Faker $faker) {
return [
'ip' => $faker->ipv4,
'port' => $faker->randomNumber(5),
];
});
$factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker $faker) {
return [
'name' => $faker->colorName,
'host' => $faker->unique()->ipv4,
'port' => 3306,
'username' => $faker->colorName,
'password' => Crypt::encrypt($faker->word),
];
});
$factory->define(Pterodactyl\Models\Database::class, function (Faker $faker) {
static $password;
return [
'database' => str_random(10),
'username' => str_random(10),
'remote' => '%',
'password' => $password ?: bcrypt('test123'),
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
];
});
$factory->define(Pterodactyl\Models\Schedule::class, function (Faker $faker) {
return [
'name' => $faker->firstName(),
];
});
$factory->define(Pterodactyl\Models\Task::class, function (Faker $faker) {
return [
'sequence_id' => $faker->randomNumber(1),
'action' => 'command',
'payload' => 'test command',
'time_offset' => 120,
'is_queued' => false,
];
});
$factory->define(Pterodactyl\Models\ApiKey::class, function (Faker $faker) {
static $token;
return [
'key_type' => ApiKey::TYPE_APPLICATION,
'identifier' => str_random(Pterodactyl\Models\ApiKey::IDENTIFIER_LENGTH),
'token' => $token ?: $token = encrypt(str_random(Pterodactyl\Models\ApiKey::KEY_LENGTH)),
'allowed_ips' => null,
'memo' => 'Test Function Key',
'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(),
];
});

View file

@ -13,7 +13,7 @@ class AddArkServiceOptionFixed extends Migration
$service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first();
// No SRCDS Service, Skipping
if (! $service) {
if (!$service) {
return;
}

View file

@ -11,13 +11,11 @@ class DeleteServiceExecutableOption extends Migration
*/
public function up()
{
DB::transaction(function () {
Schema::table('services', function (Blueprint $table) {
$table->renameColumn('file', 'folder');
$table->dropColumn('executable');
$table->text('description')->nullable()->change();
$table->text('startup')->nullable()->change();
});
Schema::table('services', function (Blueprint $table) {
$table->renameColumn('file', 'folder');
$table->dropColumn('executable');
$table->text('description')->nullable()->change();
$table->text('startup')->nullable()->change();
});
}

View file

@ -17,12 +17,12 @@ class MigrateToNewServiceSystem extends Migration
{
DB::transaction(function () {
$service = DB::table('services')->where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first();
if (! $service) {
if (!$service) {
return;
}
$options = DB::table('service_options')->where('service_id', $service->id)->get();
$options->each(function ($item) use ($options) {
$options->each(function ($item) {
if ($item->tag === 'srcds' && $item->name === 'Insurgency') {
$item->tag = 'insurgency';
} elseif ($item->tag === 'srcds' && $item->name === 'Team Fortress 2') {

View file

@ -13,7 +13,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration
$permissions = DB::table('permissions')->where('permission', 'like', '%-task%')->get();
foreach ($permissions as $record) {
$parts = explode('-', $record->permission);
if (! in_array(array_get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) {
if (!in_array(array_get($parts, 1), ['tasks', 'task']) || count($parts) !== 2) {
continue;
}
@ -31,7 +31,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration
$permissions = DB::table('permissions')->where('permission', 'like', '%-schedule%')->get();
foreach ($permissions as $record) {
$parts = explode('-', $record->permission);
if (! in_array(array_get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) {
if (!in_array(array_get($parts, 1), ['schedules', 'schedule']) || count($parts) !== 2) {
continue;
}

View file

@ -10,6 +10,7 @@ class SetupTableForKeyEncryption extends Migration
* Run the migrations.
*
* @return void
*
* @throws \Exception
* @throws \Throwable
*/
@ -29,6 +30,7 @@ class SetupTableForKeyEncryption extends Migration
* Reverse the migrations.
*
* @return void
*
* @throws \Exception
* @throws \Throwable
*/

View file

@ -1,7 +1,7 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Pterodactyl\Models\Permission;
use Illuminate\Support\Facades\Schema;
use Pterodactyl\Models\Permission as P;
@ -83,7 +83,7 @@ class MergePermissionsTableIntoSubusers extends Migration
->map(function ($value) {
return self::$permissionsMap[$value] ?? null;
})->filter(function ($value) {
return ! is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT;
return !is_null($value) && $value !== Permission::ACTION_WEBSOCKET_CONNECT;
})
// All subusers get this permission, so make sure it gets pushed into the array.
->merge([Permission::ACTION_WEBSOCKET_CONNECT])
@ -109,13 +109,13 @@ class MergePermissionsTableIntoSubusers extends Migration
$values = [];
foreach (json_decode($datum->permissions, true) as $permission) {
$v = $flipped[$permission] ?? null;
if (! empty($v)) {
if (!empty($v)) {
$values[] = $datum->id;
$values[] = $v;
}
}
if (! empty($values)) {
if (!empty($values)) {
$string = 'VALUES ' . implode(', ', array_fill(0, count($values) / 2, '(?, ?)'));
DB::insert('INSERT INTO permissions(`subuser_id`, `permission`) ' . $string, $values);

View file

@ -20,13 +20,13 @@ class CreateBackupsTable extends Migration
// to use. For now, just rename them to maintain the data.
$results = DB::select('SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = ? AND table_name LIKE ? AND table_name NOT LIKE \'%_plugin_bak\'', [
config("database.connections.{$db}.database"),
'backup%'
'backup%',
]);
// Take any of the results, most likely "backups" and "backup_logs" and rename them to have a
// suffix so data isn't completely lost, but they're no longer in the way of this migration...
foreach ($results as $result) {
Schema::rename($result->TABLE_NAME, $result->TABLE_NAME. '_plugin_bak');
Schema::rename($result->TABLE_NAME, $result->TABLE_NAME . '_plugin_bak');
}
Schema::create('backups', function (Blueprint $table) {

View file

@ -14,6 +14,7 @@ class StoreNodeTokensAsEncryptedValue extends Migration
* Run the migrations.
*
* @return void
*
* @throws \Exception
*/
public function up()

View file

@ -19,7 +19,7 @@ class AddBackupLimitToServers extends Migration
// here. If we find a result we'll actually keep the column around since we can maintain that backup
// limit, but we need to correct the column definition a bit.
$results = DB::select('SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = \'servers\' AND COLUMN_NAME = \'backup_limit\'', [
config("database.connections.{$db}.database")
config("database.connections.{$db}.database"),
]);
if (count($results) === 1) {

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserRecoveryTokensTable extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddNotesColumnForAllocations extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddBackupStateColumnToBackups extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateBytesToUnsignedBigint extends Migration
{

View file

@ -1,9 +1,9 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ModifyChecksumsColumnForBackups extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropPacksFromServers extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropPacksFromApiKeyPermissions extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropPacksTable extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropDaemonKeyTable extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeUniqueDatabaseNameToAccountForServer extends Migration
{
@ -36,6 +36,5 @@ class ChangeUniqueDatabaseNameToAccountForServer extends Migration
Schema::table('databases', function (Blueprint $table) {
$table->unique(['database_host_id', 'database']);
});
}
}

View file

@ -1,9 +1,9 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RemoveNullableFromScheduleNameField extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFeaturesColumnToEggs extends Migration
{

View file

@ -1,9 +1,9 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class SupportMultipleDockerImagesAndUpdates extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class MakeAllocationFieldsJson extends Migration
{

View file

@ -1,8 +1,8 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFileDenylistToEggConfigs extends Migration
{

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCronMonth extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('schedules', function (Blueprint $table) {
$table->string('cron_month')->after('cron_day_of_week');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('schedules', function (Blueprint $table) {
$table->dropColumn('cron_month');
});
}
}