From 3bf5a718021fcf4a08699f83a1829b502c54a662 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Fri, 25 Nov 2022 15:29:04 -0500 Subject: [PATCH] PostgreSQL Support (#4486) Co-authored-by: Matthew Penner --- .env.ci | 20 --- .github/workflows/ci.yaml | 115 ++++++++++++++++-- .github/workflows/lint.yaml | 3 - .../Api/Client/ClientController.php | 5 + app/Models/Node.php | 4 +- app/Models/User.php | 4 +- app/Providers/AppServiceProvider.php | 4 +- app/Providers/HashidsServiceProvider.php | 9 +- app/Providers/RepositoryServiceProvider.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- app/Providers/SettingsServiceProvider.php | 2 +- .../Eloquent/AllocationRepository.php | 6 +- .../Eloquent/EloquentRepository.php | 15 ++- app/Repositories/Eloquent/NodeRepository.php | 6 +- .../Deployment/FindViableNodesService.php | 8 +- bootstrap/tests.php | 2 + config/database.php | 15 +++ ...016_01_23_195641_add_allocations_table.php | 5 +- .../2016_01_23_195851_add_api_keys.php | 5 +- .../2016_01_23_200044_add_api_permissions.php | 5 +- .../2016_01_23_200159_add_downloads.php | 5 +- ..._01_23_200421_create_failed_jobs_table.php | 5 +- .../2016_01_23_200440_create_jobs_table.php | 6 +- .../2016_01_23_200528_add_locations.php | 5 +- .../2016_01_23_200648_add_nodes.php | 7 +- .../2016_01_23_201433_add_password_resets.php | 5 +- .../2016_01_23_201531_add_permissions.php | 5 +- ...2016_01_23_201649_add_server_variables.php | 5 +- .../2016_01_23_201748_add_servers.php | 5 +- .../2016_01_23_202544_add_service_options.php | 5 +- ...2016_01_23_202731_add_service_varibles.php | 5 +- .../2016_01_23_202943_add_services.php | 5 +- ...016_01_23_203119_create_settings_table.php | 5 +- .../2016_01_23_203150_add_subusers.php | 5 +- .../2016_01_23_203159_add_users.php | 5 +- ...016_01_23_203947_create_sessions_table.php | 5 +- ...01_25_234418_rename_permissions_column.php | 5 +- ...2016_02_07_172148_add_databases_tables.php | 5 +- ...2_07_181319_add_database_servers_table.php | 5 +- ...306_add_service_option_default_startup.php | 5 +- ..._02_20_155318_add_unique_service_field.php | 7 +- .../2016_02_27_163411_add_tasks_table.php | 5 +- .../2016_02_27_163447_add_tasks_log_table.php | 5 +- ...3_18_155649_add_nullable_field_lastrun.php | 24 ---- .../2016_08_30_212718_add_ip_alias.php | 5 +- ..._08_30_213301_modify_ip_storage_method.php | 5 +- ...9_01_193520_add_suspension_for_servers.php | 5 +- ...2016_09_01_211924_remove_active_column.php | 5 +- ...09_02_190647_add_sftp_password_storage.php | 5 +- .../2016_09_04_171338_update_jobs_tables.php | 10 +- ..._09_04_172028_update_failed_jobs_table.php | 4 +- ...9_04_182835_create_notifications_table.php | 5 +- ...016_09_07_163017_add_unique_identifier.php | 4 +- ..._09_14_145945_allow_longer_regex_field.php | 4 +- ...6_09_17_194246_add_docker_image_column.php | 5 +- ...9_21_165554_update_servers_column_name.php | 4 +- ..._09_29_213518_rename_double_insurgency.php | 4 +- .../2016_10_07_152117_build_api_log_table.php | 4 +- .../2016_10_14_164802_update_api_keys.php | 4 +- ...16_10_23_181719_update_misnamed_bungee.php | 4 +- ..._10_23_193810_add_foreign_keys_servers.php | 56 ++++----- ...6_10_23_201624_add_foreign_allocations.php | 23 ++-- ...2016_10_23_202222_add_foreign_api_keys.php | 8 +- ..._23_202703_add_foreign_api_permissions.php | 15 ++- ...23_202953_add_foreign_database_servers.php | 8 +- ...016_10_23_203105_add_foreign_databases.php | 12 +- .../2016_10_23_203335_add_foreign_nodes.php | 15 ++- ...6_10_23_203522_add_foreign_permissions.php | 12 +- ...23_203857_add_foreign_server_variables.php | 18 +-- ..._23_204157_add_foreign_service_options.php | 15 ++- ...3_204321_add_foreign_service_variables.php | 15 ++- ...2016_10_23_204454_add_foreign_subusers.php | 12 +- .../2016_10_23_204610_add_foreign_tasks.php | 4 +- ...04_000949_add_ark_service_option_fixed.php | 4 +- .../2016_11_11_220649_add_pack_support.php | 4 +- ...6_11_11_231731_set_service_name_unique.php | 4 +- .../2016_11_27_142519_add_pack_column.php | 4 +- ...1_173018_add_configurable_upload_limit.php | 4 +- ...12_02_185206_correct_service_variables.php | 4 +- ...7_01_03_150436_fix_misnamed_option_tag.php | 4 +- ...create_node_configuration_tokens_table.php | 4 +- .../2017_01_12_135449_add_more_user_data.php | 4 +- .../2017_02_02_175548_UpdateColumnNames.php | 29 ++--- .../2017_02_03_140948_UpdateNodesTable.php | 10 +- .../2017_02_03_155554_RenameColumns.php | 18 ++- .../2017_02_05_164123_AdjustColumnNames.php | 11 +- ...64516_AdjustColumnNamesForServicePacks.php | 11 +- ...2_09_174834_SetupPermissionsPivotTable.php | 18 ++- ...7_02_10_171858_UpdateAPIKeyColumnNames.php | 8 +- ...3_224254_UpdateNodeConfigTokensColumns.php | 4 +- ...5_212803_DeleteServiceExecutableOption.php | 4 +- ..._10_162934_AddNewServiceOptionsColumns.php | 4 +- ...03_10_173607_MigrateToNewServiceSystem.php | 4 +- ..._ChangeServiceVariablesValidationRules.php | 4 +- ...150648_MoveFunctionsFromFileToDatabase.php | 4 +- ...5631_RenameServicePacksToSingluarPacks.php | 4 +- ...17_03_14_200326_AddLockedStatusToTable.php | 4 +- ...eOrganizeDatabaseServersToDatabaseHost.php | 4 +- ..._03_16_181515_CleanupDatabasesDatabase.php | 4 +- ...2017_03_18_204953_AddForeignKeyToPacks.php | 4 +- ...3_31_221948_AddServerDescriptionColumn.php | 4 +- ..._163232_DropDeletedAtColumnFromServers.php | 4 +- .../2017_04_15_125021_UpgradeTaskSystem.php | 4 +- ...4_20_171943_AddScriptsToServiceOptions.php | 4 +- ...1432_AddServiceScriptTrackingToServers.php | 4 +- ...7_04_27_145300_AddCopyScriptFromColumn.php | 4 +- ...ConnectionOverSSLWithDaemonBehindProxy.php | 4 +- .../2017_05_01_141528_DeleteDownloadTable.php | 4 +- ...01_141559_DeleteNodeConfigurationTable.php | 4 +- ..._06_10_152951_add_external_id_to_users.php | 4 +- ...23_ChangeForeignKeyToBeOnCascadeDelete.php | 4 +- ...eUserPermissionsToDeleteOnUserDeletion.php | 4 +- ...llocationToReferenceNullOnServerDelete.php | 4 +- ...DeletionWhenAServerOrVariableIsDeleted.php | 4 +- ...33_DeleteTaskWhenParentServerIsDeleted.php | 4 +- ...ValuesForDatabaseHostWhenNodeIsDeleted.php | 4 +- ...4_AllowNegativeValuesForOverallocation.php | 6 +- ...SetAllocationUnqiueUsingMultipleFields.php | 4 +- ...adeDeletionWhenAParentServiceIsDeleted.php | 4 +- ...vePackWhenParentServiceOptionIsDeleted.php | 4 +- ...9_RenameTasksTableForStructureRefactor.php | 4 +- ...2017_09_10_225941_CreateSchedulesTable.php | 4 +- ...230309_CreateNewTasksTableForSchedules.php | 4 +- ..._002938_TransferOldTasksToNewScheduler.php | 63 +++++----- ...dPermissionsToPointToNewScheduleSystem.php | 4 +- ...017_09_23_170933_CreateDaemonKeysTable.php | 4 +- ...628_RemoveDaemonSecretFromServersTable.php | 4 +- ...22_RemoveDaemonSecretFromSubusersTable.php | 5 +- ...angeServicesToUseAMoreUniqueIdentifier.php | 4 +- ...ngeToABetterUniqueServiceConfiguration.php | 4 +- ...cadeDeletionWhenServiceOptionIsDeleted.php | 4 +- ...10_06_214026_ServicesToNestsConversion.php | 5 +- ..._214053_ServiceOptionsToEggsConversion.php | 5 +- ...rviceVariablesToEggVariablesConversion.php | 5 +- ..._24_222238_RemoveLegacySFTPInformation.php | 4 +- ...1922_Add2FaLastAuthorizationTimeColumn.php | 4 +- ...122708_MigratePubPrivFormatToSingleKey.php | 29 +++-- ...84012_DropAllocationsWhenNodeIsDeleted.php | 4 +- ...220426_MigrateSettingsTableToNewFormat.php | 4 +- ...22821_AllowNegativeValuesForServerSwap.php | 8 +- ...1_11_213943_AddApiKeyPermissionColumns.php | 8 +- ...1_13_142012_SetupTableForKeyEncryption.php | 8 +- .../2018_01_13_145209_AddLastUsedAtColumn.php | 8 +- ...02_04_145617_AllowTextInUserExternalId.php | 8 +- ...ove_unique_index_on_external_id_column.php | 8 +- ..._unique_allocation_id_on_servers_table.php | 8 +- ...dd_external_id_column_to_servers_table.php | 8 +- ...152_remove_default_null_value_on_table.php | 6 +- ...fine_unique_index_on_users_external_id.php | 8 +- ...nd_port_limit_columns_to_servers_table.php | 8 +- ..._03_15_124536_add_description_to_nodes.php | 8 +- ..._05_04_123826_add_maintenance_to_nodes.php | 8 +- ...ow_egg_variables_to_have_longer_values.php | 8 +- ...server_variables_to_have_longer_values.php | 8 +- ...2328_set_allocation_limit_default_null.php | 8 +- ...1_fix_unique_index_to_account_for_host.php | 8 +- ..._merge_permissions_table_into_subusers.php | 15 +-- ...20_03_22_164814_drop_permissions_table.php | 8 +- ...24_add_threads_column_to_servers_table.php | 8 +- ...2020_04_03_230614_create_backups_table.php | 8 +- ...4_04_131016_add_table_server_transfers.php | 14 +-- ...4_store_node_tokens_as_encrypted_value.php | 11 +- ..._17_203438_allow_nullable_descriptions.php | 8 +- ...4_22_055500_add_max_connections_column.php | 8 +- ..._26_111208_add_backup_limit_to_servers.php | 8 +- .../2020_05_20_234655_add_mounts_table.php | 8 +- ...20_05_21_192756_add_mount_server_table.php | 8 +- ...3612_create_user_recovery_tokens_table.php | 8 +- ...01845_add_notes_column_for_allocations.php | 8 +- ...533_add_backup_state_column_to_backups.php | 8 +- ...132500_update_bytes_to_unsigned_bigint.php | 8 +- ...31_modify_checksums_column_for_backups.php | 8 +- ...0_09_13_110007_drop_packs_from_servers.php | 8 +- ...21_drop_packs_from_api_key_permissions.php | 8 +- .../2020_09_13_110047_drop_packs_table.php | 8 +- ...020_09_13_113503_drop_daemon_key_table.php | 8 +- ...ue_database_name_to_account_for_server.php | 8 +- ...move_nullable_from_schedule_name_field.php | 8 +- ..._02_201014_add_features_column_to_eggs.php | 8 +- ...ort_multiple_docker_images_and_updates.php | 31 +++-- ...uccessful_nullable_in_server_transfers.php | 8 +- ...chived_field_to_server_transfers_table.php | 12 +- ..._24_092449_make_allocation_fields_json.php | 34 ------ ..._add_upload_id_column_to_backups_table.php | 8 +- ...53937_add_file_denylist_to_egg_configs.php | 8 +- .../2021_01_13_013420_add_cron_month.php | 8 +- ...1_01_17_102401_create_audit_logs_table.php | 8 +- ...52623_add_generic_server_status_column.php | 24 ++-- ...26_210502_update_file_denylist_to_json.php | 8 +- ...205021_add_index_for_server_and_action.php | 8 +- ..._23_212657_make_sftp_port_unsigned_int.php | 8 +- ...n_month_field_to_have_value_if_missing.php | 14 +-- ...dd_continue_on_failure_option_to_tasks.php | 8 +- ...when_server_online_option_to_schedules.php | 8 +- ...01016_add_support_for_locking_a_backup.php | 8 +- ...21_07_12_013420_remove_userinteraction.php | 39 ++++-- ...7_17_211512_create_user_ssh_keys_table.php | 4 +- ...d_to_default_to_false_on_backups_table.php | 8 +- ...1_add_foreign_keys_to_mount_node_table.php | 8 +- ...add_foreign_keys_to_mount_server_table.php | 8 +- ...21_add_foreign_keys_to_egg_mount_table.php | 8 +- ...022_01_25_030847_drop_google_analytics.php | 14 +-- ...migrate_egg_images_array_to_new_format.php | 6 +- ...5_28_135717_create_activity_logs_table.php | 8 +- ...40349_create_activity_log_actors_table.php | 8 +- ...rack_api_key_usage_for_activity_events.php | 8 +- ...force_outgoing_ip_column_to_eggs_table.php | 8 +- ...d_installed_at_column_to_servers_table.php | 8 +- ...files_column_nullable_on_backups_table.php | 27 ++++ ...ix_language_column_type_on_users_table.php | 36 ++++++ phpunit.xml | 2 +- .../Location/LocationControllerTest.php | 2 +- .../Application/Nests/EggControllerTest.php | 2 +- .../Application/Nests/NestControllerTest.php | 2 +- .../Users/ExternalUserControllerTest.php | 2 +- .../Application/Users/UserControllerTest.php | 2 +- .../Api/Client/ClientControllerTest.php | 26 ++-- .../Startup/GetStartupAndVariablesTest.php | 2 +- tests/Integration/IntegrationTestCase.php | 2 +- .../Servers/ServerCreationServiceTest.php | 7 +- .../StartupModificationServiceTest.php | 19 +-- .../Servers/VariableValidatorServiceTest.php | 11 +- tests/Traits/MocksPdoConnection.php | 48 -------- 223 files changed, 912 insertions(+), 1052 deletions(-) delete mode 100644 .env.ci delete mode 100644 database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php delete mode 100644 database/migrations/2020_12_24_092449_make_allocation_fields_json.php create mode 100644 database/migrations/2022_11_01_163744_make_ignored_files_column_nullable_on_backups_table.php create mode 100644 database/migrations/2022_11_01_165830_fix_language_column_type_on_users_table.php delete mode 100644 tests/Traits/MocksPdoConnection.php diff --git a/.env.ci b/.env.ci deleted file mode 100644 index 1a9e848e3..000000000 --- a/.env.ci +++ /dev/null @@ -1,20 +0,0 @@ -APP_ENV=testing -APP_DEBUG=true -APP_KEY=SomeRandomString3232RandomString -APP_THEME=pterodactyl -APP_TIMEZONE=UTC -APP_URL=http://localhost/ -APP_ENVIRONMENT_ONLY=true - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_DATABASE=testing -DB_USERNAME=root -DB_PASSWORD= - -CACHE_DRIVER=array -SESSION_DRIVER=array -MAIL_DRIVER=array -QUEUE_DRIVER=sync - -HASHIDS_SALT=test123 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4da19b6ed..28ce63e4a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,23 +11,43 @@ on: - "1.0-develop" jobs: - tests: - name: Tests + mysql: + name: MySQL runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - php: [8.0, 8.1] - database: ["mariadb:10.2", "mysql:8"] + php: [8.1] + database: ["mariadb:10.2", "mariadb:10.9", "mysql:8"] services: database: - image: ${{ matrix.database }} + image: docker.io/library/${{ matrix.database }} env: MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_DATABASE: testing ports: - - 3306 + - 3306/tcp options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + env: + APP_ENV: testing + APP_DEBUG: "true" + APP_KEY: SomeRandomString3232RandomString + APP_THEME: pterodactyl + APP_TIMEZONE: UTC + APP_URL: http://localhost/ + APP_ENVIRONMENT_ONLY: "true" + + DB_CONNECTION: mysql + DB_HOST: 127.0.0.1 + DB_DATABASE: testing + DB_USERNAME: root + + CACHE_DRIVER: array + MAIL_MAILER: array + SESSION_DRIVER: array + QUEUE_CONNECTION: sync + + HASHIDS_SALT: test123 steps: - name: Code Checkout uses: actions/checkout@v3 @@ -53,9 +73,6 @@ jobs: tools: composer:v2 coverage: none - - name: Setup .env - run: cp .env.ci .env - - name: Install dependencies run: composer install --no-interaction --no-progress --no-suggest --prefer-dist @@ -69,4 +86,82 @@ jobs: run: vendor/bin/phpunit tests/Integration env: DB_PORT: ${{ job.services.database.ports[3306] }} - DB_USERNAME: root + + postgres: + name: PostgreSQL + runs-on: ubuntu-20.04 + if: "!contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'ci skip')" + strategy: + fail-fast: false + matrix: + php: [8.1] + database: ["postgres:13", "postgres:14", "postgres:15"] + services: + database: + image: docker.io/library/${{ matrix.database }} + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: testing + ports: + - 5432/tcp + options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 + env: + APP_ENV: testing + APP_DEBUG: "true" + APP_KEY: SomeRandomString3232RandomString + APP_THEME: pterodactyl + APP_TIMEZONE: UTC + APP_URL: http://localhost/ + APP_ENVIRONMENT_ONLY: "true" + + DB_CONNECTION: pgsql + DB_HOST: 127.0.0.1 + DB_DATABASE: testing + DB_USERNAME: postgres + DB_PASSWORD: postgres + + CACHE_DRIVER: array + MAIL_MAILER: array + SESSION_DRIVER: array + QUEUE_CONNECTION: sync + + HASHIDS_SALT: test123 + steps: + - name: Code Checkout + uses: actions/checkout@v3 + + - name: Get cache directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/.php_cs.cache + ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-cache-${{ matrix.php }}-${{ hashFiles('**.composer.lock') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: bcmath, cli, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip + tools: composer:v2 + coverage: none + + - name: Install dependencies + run: composer install --no-interaction --no-progress --no-suggest --prefer-dist + + - name: Unit tests + run: vendor/bin/phpunit --bootstrap vendor/autoload.php tests/Unit + if: ${{ always() }} + env: + DB_HOST: UNIT_NO_DB + + - name: Integration tests + run: vendor/bin/phpunit tests/Integration + env: + DB_PORT: ${{ job.services.database.ports[5432] }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 4ac292b68..a48c6b14e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -26,9 +26,6 @@ jobs: tools: composer:v2 coverage: none - - name: Setup .env - run: cp .env.ci .env - - name: Install dependencies run: composer install --no-interaction --no-progress --no-suggest --prefer-dist diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php index 9afb72628..dcdb5964b 100644 --- a/app/Http/Controllers/Api/Client/ClientController.php +++ b/app/Http/Controllers/Api/Client/ClientController.php @@ -40,6 +40,11 @@ class ClientController extends ClientApiController AllowedFilter::custom('*', new MultiFieldServerFilter()), ]); + $loweredBindings = collect($builder->getBindings()) + ->map(fn ($f, $key) => is_string($f) ? strtolower($f) : $f) + ->all(); + $builder->setBindings($loweredBindings); + $type = $request->input('type'); // Either return all the servers the user has access to because they are an admin `?type=admin` or // just return all the servers the user has access to because they are the owner or a subuser of the diff --git a/app/Models/Node.php b/app/Models/Node.php index 62ec82871..504a28c24 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -225,8 +225,8 @@ class Node extends Model */ public function isViable(int $memory, int $disk): bool { - $memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100)); - $diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100)); + $memoryLimit = $this->memory * (1.0 + ($this->memory_overallocate / 100.0)); + $diskLimit = $this->disk * (1.0 + ($this->disk_overallocate / 100.0)); return ($this->sum_memory + $memory) <= $memoryLimit && ($this->sum_disk + $disk) <= $diskLimit; } diff --git a/app/Models/User.php b/app/Models/User.php index df8271cf4..eb3c15d22 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -76,7 +76,9 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; * @method static Builder|User whereUsername($value) * @method static Builder|User whereUuid($value) * - * @mixin \Eloquent + * @mixin \Barryvdh\LaravelIdeHelper\Eloquent + * @mixin \Illuminate\Database\Query\Builder + * @mixin \Illuminate\Database\Eloquent\Builder */ class User extends Model implements AuthenticatableContract, diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d4ffdadbb..6a805bad3 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,12 +2,12 @@ namespace Pterodactyl\Providers; -use View; -use Cache; use Pterodactyl\Models; use Illuminate\Support\Str; use Illuminate\Support\Facades\URL; use Illuminate\Pagination\Paginator; +use Illuminate\Support\Facades\View; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Schema; use Illuminate\Support\ServiceProvider; use Pterodactyl\Extensions\Themes\Theme; diff --git a/app/Providers/HashidsServiceProvider.php b/app/Providers/HashidsServiceProvider.php index f094878d0..4e48208ef 100644 --- a/app/Providers/HashidsServiceProvider.php +++ b/app/Providers/HashidsServiceProvider.php @@ -14,13 +14,10 @@ class HashidsServiceProvider extends ServiceProvider public function register() { $this->app->singleton(HashidsInterface::class, function () { - /** @var \Illuminate\Contracts\Config\Repository $config */ - $config = $this->app['config']; - return new Hashids( - $config->get('hashids.salt', ''), - $config->get('hashids.length', 0), - $config->get('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890') + config('hashids.salt', ''), + config('hashids.length', 0), + config('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890') ); }); diff --git a/app/Providers/RepositoryServiceProvider.php b/app/Providers/RepositoryServiceProvider.php index 8a0434f52..e5a16dd50 100644 --- a/app/Providers/RepositoryServiceProvider.php +++ b/app/Providers/RepositoryServiceProvider.php @@ -41,7 +41,7 @@ use Pterodactyl\Contracts\Repository\ServerVariableRepositoryInterface; class RepositoryServiceProvider extends ServiceProvider { /** - * Register all of the repository bindings. + * Register all the repository bindings. */ public function register() { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index f5ac5565d..25f18c524 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider }); // This is needed to make use of the "resolveRouteBinding" functionality in the - // model. Without it you'll never trigger that logic flow thus resulting in a 404 + // model. Without it, you'll never trigger that logic flow thus resulting in a 404 // error because we request databases with a HashID, and not with a normal ID. Route::model('database', Database::class); diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php index 9c8a7445e..e2bcdafe6 100644 --- a/app/Providers/SettingsServiceProvider.php +++ b/app/Providers/SettingsServiceProvider.php @@ -80,7 +80,7 @@ class SettingsServiceProvider extends ServiceProvider if (in_array($key, self::$encrypted)) { try { $value = $encrypter->decrypt($value); - } catch (DecryptException $exception) { + } catch (DecryptException) { } } diff --git a/app/Repositories/Eloquent/AllocationRepository.php b/app/Repositories/Eloquent/AllocationRepository.php index 6eb8b6d1e..01ed1c5be 100644 --- a/app/Repositories/Eloquent/AllocationRepository.php +++ b/app/Repositories/Eloquent/AllocationRepository.php @@ -40,14 +40,14 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos */ protected function getDiscardableDedicatedAllocations(array $nodes = []): array { - $query = Allocation::query()->selectRaw('CONCAT_WS("-", node_id, ip) as result'); + $query = Allocation::query()->selectRaw('CONCAT_WS(\'-\', node_id, ip) as result'); if (!empty($nodes)) { $query->whereIn('node_id', $nodes); } return $query->whereNotNull('server_id') - ->groupByRaw('CONCAT(node_id, ip)') + ->groupByRaw('result') ->get() ->pluck('result') ->toArray(); @@ -89,7 +89,7 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos if (!empty($discard)) { $query->whereNotIn( - $this->getBuilder()->raw('CONCAT_WS("-", node_id, ip)'), + $this->getBuilder()->raw('CONCAT_WS(\'-\', node_id, ip)'), $discard ); } diff --git a/app/Repositories/Eloquent/EloquentRepository.php b/app/Repositories/Eloquent/EloquentRepository.php index a4e7f2fd7..a78295be4 100644 --- a/app/Repositories/Eloquent/EloquentRepository.php +++ b/app/Repositories/Eloquent/EloquentRepository.php @@ -2,9 +2,12 @@ namespace Pterodactyl\Repositories\Eloquent; +use PDO; +use RuntimeException; use Illuminate\Http\Request; use Webmozart\Assert\Assert; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\DB; use Illuminate\Database\Eloquent\Model; use Pterodactyl\Repositories\Repository; use Illuminate\Database\Eloquent\Builder; @@ -271,7 +274,17 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf return sprintf('(%s)', $grammar->parameterize($record)); })->implode(', '); - $statement = "insert ignore into $table ($columns) values $parameters"; + $driver = DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME); + switch ($driver) { + case 'mysql': + $statement = "insert ignore into $table ($columns) values $parameters"; + break; + case 'pgsql': + $statement = "insert into $table ($columns) values $parameters on conflict do nothing"; + break; + default: + throw new RuntimeException("Unsupported database driver \"$driver\" for insert ignore."); + } return $this->getBuilder()->getConnection()->statement($statement, $bindings); } diff --git a/app/Repositories/Eloquent/NodeRepository.php b/app/Repositories/Eloquent/NodeRepository.php index fe019e50a..d7a3818f3 100644 --- a/app/Repositories/Eloquent/NodeRepository.php +++ b/app/Repositories/Eloquent/NodeRepository.php @@ -22,7 +22,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa public function getUsageStats(Node $node): array { $stats = $this->getBuilder() - ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') + ->selectRaw('COALESCE(SUM(servers.memory), 0) as sum_memory, COALESCE(SUM(servers.disk), 0) as sum_disk') ->join('servers', 'servers.node_id', '=', 'nodes.id') ->where('node_id', '=', $node->id) ->first(); @@ -54,7 +54,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa public function getUsageStatsRaw(Node $node): array { $stats = $this->getBuilder()->select( - $this->getBuilder()->raw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') + $this->getBuilder()->raw('COALESCE(SUM(servers.memory), 0) as sum_memory, COALESCE(SUM(servers.disk), 0) as sum_disk') )->join('servers', 'servers.node_id', '=', 'nodes.id')->where('node_id', $node->id)->first(); return collect(['disk' => $stats->sum_disk, 'memory' => $stats->sum_memory])->mapWithKeys(function ($value, $key) use ($node) { @@ -143,7 +143,7 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa { $instance = $this->getBuilder() ->select(['nodes.id', 'nodes.fqdn', 'nodes.scheme', 'nodes.daemon_token', 'nodes.daemonListen', 'nodes.memory', 'nodes.disk', 'nodes.memory_overallocate', 'nodes.disk_overallocate']) - ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk') + ->selectRaw('COALESCE(SUM(servers.memory), 0) as sum_memory, COALESCE(SUM(servers.disk), 0) as sum_disk') ->leftJoin('servers', 'servers.node_id', '=', 'nodes.id') ->where('nodes.id', $node_id); diff --git a/app/Services/Deployment/FindViableNodesService.php b/app/Services/Deployment/FindViableNodesService.php index 71c830bf9..a95211c3f 100644 --- a/app/Services/Deployment/FindViableNodesService.php +++ b/app/Services/Deployment/FindViableNodesService.php @@ -72,8 +72,8 @@ class FindViableNodesService Assert::integer($this->memory, 'Memory usage must be an int, got %s'); $query = Node::query()->select('nodes.*') - ->selectRaw('IFNULL(SUM(servers.memory), 0) as sum_memory') - ->selectRaw('IFNULL(SUM(servers.disk), 0) as sum_disk') + ->selectRaw('COALESCE(SUM(servers.memory), 0) as sum_memory') + ->selectRaw('COALESCE(SUM(servers.disk), 0) as sum_disk') ->leftJoin('servers', 'servers.node_id', '=', 'nodes.id') ->where('nodes.public', 1); @@ -82,8 +82,8 @@ class FindViableNodesService } $results = $query->groupBy('nodes.id') - ->havingRaw('(IFNULL(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1 + (nodes.memory_overallocate / 100)))', [$this->memory]) - ->havingRaw('(IFNULL(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1 + (nodes.disk_overallocate / 100)))', [$this->disk]); + ->havingRaw('(COALESCE(SUM(servers.memory), 0) + ?) <= (nodes.memory * (1.0 + (nodes.memory_overallocate / 100.0)))', [$this->memory]) + ->havingRaw('(COALESCE(SUM(servers.disk), 0) + ?) <= (nodes.disk * (1.0 + (nodes.disk_overallocate / 100.0)))', [$this->disk]); if (!is_null($page)) { $results = $results->paginate($perPage ?? 50, ['*'], 'page', $page); diff --git a/bootstrap/tests.php b/bootstrap/tests.php index 5b5449355..66f23147d 100644 --- a/bootstrap/tests.php +++ b/bootstrap/tests.php @@ -40,6 +40,8 @@ if (!env('SKIP_MIGRATIONS')) { $output->writeln('Seeding database for Integration tests...' . PHP_EOL); $kernel->call('db:seed'); + + $output->writeln('Database configured, running Integration tests...' . PHP_EOL); } else { $output->writeln(PHP_EOL . 'Skipping database migrations...' . PHP_EOL); } diff --git a/config/database.php b/config/database.php index b3a460ba2..1a8d9bf65 100644 --- a/config/database.php +++ b/config/database.php @@ -57,6 +57,21 @@ return [ PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => env('MYSQL_ATTR_SSL_VERIFY_SERVER_CERT', true), ]) : [], ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'panel'), + 'username' => env('DB_USERNAME', 'pterodactyl'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => env('DB_PREFIX', ''), + 'prefix_indexes' => true, + 'search_path' => 'public', + 'sslmode' => 'prefer', + ], ], /* diff --git a/database/migrations/2016_01_23_195641_add_allocations_table.php b/database/migrations/2016_01_23_195641_add_allocations_table.php index cfff2b359..e6306c3b2 100644 --- a/database/migrations/2016_01_23_195641_add_allocations_table.php +++ b/database/migrations/2016_01_23_195641_add_allocations_table.php @@ -1,5 +1,6 @@ increments('id'); @@ -23,7 +24,7 @@ class AddAllocationsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('allocations'); } diff --git a/database/migrations/2016_01_23_195851_add_api_keys.php b/database/migrations/2016_01_23_195851_add_api_keys.php index af7deb62d..1a7824b1c 100644 --- a/database/migrations/2016_01_23_195851_add_api_keys.php +++ b/database/migrations/2016_01_23_195851_add_api_keys.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class AddApiKeys extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('api_keys'); } diff --git a/database/migrations/2016_01_23_200044_add_api_permissions.php b/database/migrations/2016_01_23_200044_add_api_permissions.php index e6f6bcbf8..e587da0a3 100644 --- a/database/migrations/2016_01_23_200044_add_api_permissions.php +++ b/database/migrations/2016_01_23_200044_add_api_permissions.php @@ -1,5 +1,6 @@ increments('id'); @@ -20,7 +21,7 @@ class AddApiPermissions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('api_permissions'); } diff --git a/database/migrations/2016_01_23_200159_add_downloads.php b/database/migrations/2016_01_23_200159_add_downloads.php index b1771c5e4..9424578fb 100644 --- a/database/migrations/2016_01_23_200159_add_downloads.php +++ b/database/migrations/2016_01_23_200159_add_downloads.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class AddDownloads extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('downloads'); } diff --git a/database/migrations/2016_01_23_200421_create_failed_jobs_table.php b/database/migrations/2016_01_23_200421_create_failed_jobs_table.php index 83923e7d0..50d42ccc9 100644 --- a/database/migrations/2016_01_23_200421_create_failed_jobs_table.php +++ b/database/migrations/2016_01_23_200421_create_failed_jobs_table.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class CreateFailedJobsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('failed_jobs'); } diff --git a/database/migrations/2016_01_23_200440_create_jobs_table.php b/database/migrations/2016_01_23_200440_create_jobs_table.php index 277acae31..fe7f9686c 100644 --- a/database/migrations/2016_01_23_200440_create_jobs_table.php +++ b/database/migrations/2016_01_23_200440_create_jobs_table.php @@ -1,5 +1,6 @@ bigIncrements('id'); @@ -19,6 +20,7 @@ class CreateJobsTable extends Migration $table->unsignedInteger('reserved_at')->nullable(); $table->unsignedInteger('available_at'); $table->unsignedInteger('created_at'); + $table->index(['queue', 'reserved', 'reserved_at']); }); } @@ -26,7 +28,7 @@ class CreateJobsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('jobs'); } diff --git a/database/migrations/2016_01_23_200528_add_locations.php b/database/migrations/2016_01_23_200528_add_locations.php index b34a5fbcc..38d1e1710 100644 --- a/database/migrations/2016_01_23_200528_add_locations.php +++ b/database/migrations/2016_01_23_200528_add_locations.php @@ -1,5 +1,6 @@ increments('id'); @@ -21,7 +22,7 @@ class AddLocations extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('locations'); } diff --git a/database/migrations/2016_01_23_200648_add_nodes.php b/database/migrations/2016_01_23_200648_add_nodes.php index 52c0a29e6..371ebf049 100644 --- a/database/migrations/2016_01_23_200648_add_nodes.php +++ b/database/migrations/2016_01_23_200648_add_nodes.php @@ -1,5 +1,6 @@ increments('id'); @@ -23,7 +24,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(); }); @@ -32,7 +33,7 @@ class AddNodes extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('nodes'); } diff --git a/database/migrations/2016_01_23_201433_add_password_resets.php b/database/migrations/2016_01_23_201433_add_password_resets.php index 0584e3617..47c49146d 100644 --- a/database/migrations/2016_01_23_201433_add_password_resets.php +++ b/database/migrations/2016_01_23_201433_add_password_resets.php @@ -1,5 +1,6 @@ string('email')->index(); @@ -20,7 +21,7 @@ class AddPasswordResets extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('password_resets'); } diff --git a/database/migrations/2016_01_23_201531_add_permissions.php b/database/migrations/2016_01_23_201531_add_permissions.php index 12c9bbe0f..120a0e034 100644 --- a/database/migrations/2016_01_23_201531_add_permissions.php +++ b/database/migrations/2016_01_23_201531_add_permissions.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class AddPermissions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('permissions'); } diff --git a/database/migrations/2016_01_23_201649_add_server_variables.php b/database/migrations/2016_01_23_201649_add_server_variables.php index d9a436e6d..596c619d0 100644 --- a/database/migrations/2016_01_23_201649_add_server_variables.php +++ b/database/migrations/2016_01_23_201649_add_server_variables.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class AddServerVariables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('server_variables'); } diff --git a/database/migrations/2016_01_23_201748_add_servers.php b/database/migrations/2016_01_23_201748_add_servers.php index 5e1061069..901c1ff5c 100644 --- a/database/migrations/2016_01_23_201748_add_servers.php +++ b/database/migrations/2016_01_23_201748_add_servers.php @@ -1,5 +1,6 @@ increments('id'); @@ -39,7 +40,7 @@ class AddServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('servers'); } diff --git a/database/migrations/2016_01_23_202544_add_service_options.php b/database/migrations/2016_01_23_202544_add_service_options.php index 7b0a33609..382f67a1a 100644 --- a/database/migrations/2016_01_23_202544_add_service_options.php +++ b/database/migrations/2016_01_23_202544_add_service_options.php @@ -1,5 +1,6 @@ increments('id'); @@ -24,7 +25,7 @@ class AddServiceOptions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('service_options'); } diff --git a/database/migrations/2016_01_23_202731_add_service_varibles.php b/database/migrations/2016_01_23_202731_add_service_varibles.php index e79fa1fe9..bb96d83b6 100644 --- a/database/migrations/2016_01_23_202731_add_service_varibles.php +++ b/database/migrations/2016_01_23_202731_add_service_varibles.php @@ -1,5 +1,6 @@ increments('id'); @@ -28,7 +29,7 @@ class AddServiceVaribles extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('service_variables'); } diff --git a/database/migrations/2016_01_23_202943_add_services.php b/database/migrations/2016_01_23_202943_add_services.php index 31f723445..caddd964b 100644 --- a/database/migrations/2016_01_23_202943_add_services.php +++ b/database/migrations/2016_01_23_202943_add_services.php @@ -1,5 +1,6 @@ increments('id'); @@ -24,7 +25,7 @@ class AddServices extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('services'); } diff --git a/database/migrations/2016_01_23_203119_create_settings_table.php b/database/migrations/2016_01_23_203119_create_settings_table.php index 2cd6922c2..40dec55c6 100644 --- a/database/migrations/2016_01_23_203119_create_settings_table.php +++ b/database/migrations/2016_01_23_203119_create_settings_table.php @@ -1,5 +1,6 @@ string('key')->unique(); @@ -19,7 +20,7 @@ class CreateSettingsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('settings'); } diff --git a/database/migrations/2016_01_23_203150_add_subusers.php b/database/migrations/2016_01_23_203150_add_subusers.php index 2f0e46310..e7561c0fd 100644 --- a/database/migrations/2016_01_23_203150_add_subusers.php +++ b/database/migrations/2016_01_23_203150_add_subusers.php @@ -1,5 +1,6 @@ increments('id'); @@ -22,7 +23,7 @@ class AddSubusers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('subusers'); } diff --git a/database/migrations/2016_01_23_203159_add_users.php b/database/migrations/2016_01_23_203159_add_users.php index 05ace7e22..1b6f9b5bb 100644 --- a/database/migrations/2016_01_23_203159_add_users.php +++ b/database/migrations/2016_01_23_203159_add_users.php @@ -1,5 +1,6 @@ increments('id'); @@ -27,7 +28,7 @@ class AddUsers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('users'); } diff --git a/database/migrations/2016_01_23_203947_create_sessions_table.php b/database/migrations/2016_01_23_203947_create_sessions_table.php index 533fa8aa2..7f708195e 100644 --- a/database/migrations/2016_01_23_203947_create_sessions_table.php +++ b/database/migrations/2016_01_23_203947_create_sessions_table.php @@ -1,5 +1,6 @@ string('id')->unique(); @@ -23,7 +24,7 @@ class CreateSessionsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('sessions'); } diff --git a/database/migrations/2016_01_25_234418_rename_permissions_column.php b/database/migrations/2016_01_25_234418_rename_permissions_column.php index ae46dceb2..6b75986f9 100644 --- a/database/migrations/2016_01_25_234418_rename_permissions_column.php +++ b/database/migrations/2016_01_25_234418_rename_permissions_column.php @@ -1,5 +1,6 @@ renameColumn('permissions', 'permission'); @@ -18,7 +19,7 @@ class RenamePermissionsColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('permissions', function (Blueprint $table) { }); diff --git a/database/migrations/2016_02_07_172148_add_databases_tables.php b/database/migrations/2016_02_07_172148_add_databases_tables.php index 7b1048b15..26fdbf389 100644 --- a/database/migrations/2016_02_07_172148_add_databases_tables.php +++ b/database/migrations/2016_02_07_172148_add_databases_tables.php @@ -1,5 +1,6 @@ increments('id'); @@ -25,7 +26,7 @@ class AddDatabasesTables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('databases'); } diff --git a/database/migrations/2016_02_07_181319_add_database_servers_table.php b/database/migrations/2016_02_07_181319_add_database_servers_table.php index 5a6740ae6..16d2d3cf5 100644 --- a/database/migrations/2016_02_07_181319_add_database_servers_table.php +++ b/database/migrations/2016_02_07_181319_add_database_servers_table.php @@ -1,5 +1,6 @@ increments('id'); @@ -26,7 +27,7 @@ class AddDatabaseServersTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('database_servers'); } diff --git a/database/migrations/2016_02_13_154306_add_service_option_default_startup.php b/database/migrations/2016_02_13_154306_add_service_option_default_startup.php index c8255ff47..a5d14b6d5 100644 --- a/database/migrations/2016_02_13_154306_add_service_option_default_startup.php +++ b/database/migrations/2016_02_13_154306_add_service_option_default_startup.php @@ -1,5 +1,6 @@ text('executable')->after('docker_image')->nullable()->default(null); @@ -19,7 +20,7 @@ class AddServiceOptionDefaultStartup extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropColumn('executable'); diff --git a/database/migrations/2016_02_20_155318_add_unique_service_field.php b/database/migrations/2016_02_20_155318_add_unique_service_field.php index 01ff91359..241e278ff 100644 --- a/database/migrations/2016_02_20_155318_add_unique_service_field.php +++ b/database/migrations/2016_02_20_155318_add_unique_service_field.php @@ -1,5 +1,6 @@ string('file')->unique()->change(); @@ -18,10 +19,10 @@ class AddUniqueServiceField extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { - $table->dropUnique('services_file_unique'); + $table->dropUnique(['file']); }); } } diff --git a/database/migrations/2016_02_27_163411_add_tasks_table.php b/database/migrations/2016_02_27_163411_add_tasks_table.php index f4cb7b1e3..8fb1efb4a 100644 --- a/database/migrations/2016_02_27_163411_add_tasks_table.php +++ b/database/migrations/2016_02_27_163411_add_tasks_table.php @@ -1,5 +1,6 @@ increments('id'); @@ -32,7 +33,7 @@ class AddTasksTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('tasks'); } diff --git a/database/migrations/2016_02_27_163447_add_tasks_log_table.php b/database/migrations/2016_02_27_163447_add_tasks_log_table.php index 265e7fd96..6014a69b8 100644 --- a/database/migrations/2016_02_27_163447_add_tasks_log_table.php +++ b/database/migrations/2016_02_27_163447_add_tasks_log_table.php @@ -1,5 +1,6 @@ increments('id'); @@ -23,7 +24,7 @@ class AddTasksLogTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('tasks_log'); } diff --git a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php b/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php deleted file mode 100644 index 9d4752eb6..000000000 --- a/database/migrations/2016_03_18_155649_add_nullable_field_lastrun.php +++ /dev/null @@ -1,24 +0,0 @@ -wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP NULL;'); - } - - /** - * Reverse the migrations. - */ - public function down() - { - $table = DB::getQueryGrammar()->wrapTable('tasks'); - DB::statement('ALTER TABLE ' . $table . ' CHANGE `last_run` `last_run` TIMESTAMP;'); - } -} diff --git a/database/migrations/2016_08_30_212718_add_ip_alias.php b/database/migrations/2016_08_30_212718_add_ip_alias.php index 26aa5eaa5..17272a2cc 100644 --- a/database/migrations/2016_08_30_212718_add_ip_alias.php +++ b/database/migrations/2016_08_30_212718_add_ip_alias.php @@ -1,5 +1,6 @@ text('ip_alias')->nullable()->after('ip'); @@ -29,7 +30,7 @@ class AddIpAlias extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropColumn('ip_alias'); diff --git a/database/migrations/2016_08_30_213301_modify_ip_storage_method.php b/database/migrations/2016_08_30_213301_modify_ip_storage_method.php index ee7e704fb..7c8b1d46b 100644 --- a/database/migrations/2016_08_30_213301_modify_ip_storage_method.php +++ b/database/migrations/2016_08_30_213301_modify_ip_storage_method.php @@ -1,5 +1,6 @@ mediumInteger('allocation')->unsigned()->after('oom_disabled'); @@ -47,7 +48,7 @@ class ModifyIpStorageMethod extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->text('ip')->after('allocation'); diff --git a/database/migrations/2016_09_01_193520_add_suspension_for_servers.php b/database/migrations/2016_09_01_193520_add_suspension_for_servers.php index 7bfb75b20..19cd96522 100644 --- a/database/migrations/2016_09_01_193520_add_suspension_for_servers.php +++ b/database/migrations/2016_09_01_193520_add_suspension_for_servers.php @@ -1,5 +1,6 @@ tinyInteger('suspended')->unsigned()->default(0)->after('active'); @@ -18,7 +19,7 @@ class AddSuspensionForServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('suspended'); diff --git a/database/migrations/2016_09_01_211924_remove_active_column.php b/database/migrations/2016_09_01_211924_remove_active_column.php index 22a2bde13..7450c932d 100644 --- a/database/migrations/2016_09_01_211924_remove_active_column.php +++ b/database/migrations/2016_09_01_211924_remove_active_column.php @@ -1,5 +1,6 @@ dropColumn('active'); @@ -18,7 +19,7 @@ class RemoveActiveColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->tinyInteger('active')->after('name')->unsigned()->default(0); diff --git a/database/migrations/2016_09_02_190647_add_sftp_password_storage.php b/database/migrations/2016_09_02_190647_add_sftp_password_storage.php index 565957d59..57ce1f3b5 100644 --- a/database/migrations/2016_09_02_190647_add_sftp_password_storage.php +++ b/database/migrations/2016_09_02_190647_add_sftp_password_storage.php @@ -1,5 +1,6 @@ text('sftp_password')->after('username')->nullable(); @@ -18,7 +19,7 @@ class AddSftpPasswordStorage extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('sftp_password'); diff --git a/database/migrations/2016_09_04_171338_update_jobs_tables.php b/database/migrations/2016_09_04_171338_update_jobs_tables.php index 840ecacb5..4c5bff23f 100644 --- a/database/migrations/2016_09_04_171338_update_jobs_tables.php +++ b/database/migrations/2016_09_04_171338_update_jobs_tables.php @@ -9,11 +9,12 @@ class UpdateJobsTables extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('jobs', function (Blueprint $table) { - $table->dropIndex('jobs_queue_reserved_reserved_at_index'); + $table->dropIndex(['queue', 'reserved', 'reserved_at']); $table->dropColumn('reserved'); + $table->index(['queue', 'reserved_at']); }); } @@ -21,10 +22,11 @@ class UpdateJobsTables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('jobs', function (Blueprint $table) { - $table->dropIndex('jobs_queue_reserved_at_index'); + $table->dropIndex(['queue', 'reserved_at']); + $table->tinyInteger('reserved')->unsigned(); $table->index(['queue', 'reserved', 'reserved_at']); }); diff --git a/database/migrations/2016_09_04_172028_update_failed_jobs_table.php b/database/migrations/2016_09_04_172028_update_failed_jobs_table.php index a00f5f18d..b5157a1ef 100644 --- a/database/migrations/2016_09_04_172028_update_failed_jobs_table.php +++ b/database/migrations/2016_09_04_172028_update_failed_jobs_table.php @@ -9,7 +9,7 @@ class UpdateFailedJobsTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('failed_jobs', function (Blueprint $table) { $table->text('exception'); @@ -19,7 +19,7 @@ class UpdateFailedJobsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('failed_jobs', function (Blueprint $table) { $table->dropColumn('exception'); diff --git a/database/migrations/2016_09_04_182835_create_notifications_table.php b/database/migrations/2016_09_04_182835_create_notifications_table.php index 30fc23a59..8918f3009 100644 --- a/database/migrations/2016_09_04_182835_create_notifications_table.php +++ b/database/migrations/2016_09_04_182835_create_notifications_table.php @@ -1,5 +1,6 @@ string('id')->primary(); @@ -23,7 +24,7 @@ class CreateNotificationsTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('notifications'); } diff --git a/database/migrations/2016_09_07_163017_add_unique_identifier.php b/database/migrations/2016_09_07_163017_add_unique_identifier.php index e1bab9ccc..685a718a4 100644 --- a/database/migrations/2016_09_07_163017_add_unique_identifier.php +++ b/database/migrations/2016_09_07_163017_add_unique_identifier.php @@ -9,7 +9,7 @@ class AddUniqueIdentifier extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->char('author', 36)->after('id'); @@ -19,7 +19,7 @@ class AddUniqueIdentifier extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('author'); diff --git a/database/migrations/2016_09_14_145945_allow_longer_regex_field.php b/database/migrations/2016_09_14_145945_allow_longer_regex_field.php index a7df1ca1b..8d0ab04ac 100644 --- a/database/migrations/2016_09_14_145945_allow_longer_regex_field.php +++ b/database/migrations/2016_09_14_145945_allow_longer_regex_field.php @@ -9,7 +9,7 @@ class AllowLongerRegexField extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_variables', function (Blueprint $table) { $table->text('regex')->change(); @@ -19,7 +19,7 @@ class AllowLongerRegexField extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_variables', function (Blueprint $table) { $table->string('regex')->change(); diff --git a/database/migrations/2016_09_17_194246_add_docker_image_column.php b/database/migrations/2016_09_17_194246_add_docker_image_column.php index 05d26112e..0e66f649e 100644 --- a/database/migrations/2016_09_17_194246_add_docker_image_column.php +++ b/database/migrations/2016_09_17_194246_add_docker_image_column.php @@ -1,5 +1,6 @@ string('image')->after('daemonSecret'); @@ -32,7 +33,7 @@ class AddDockerImageColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('image'); diff --git a/database/migrations/2016_09_21_165554_update_servers_column_name.php b/database/migrations/2016_09_21_165554_update_servers_column_name.php index 14ae07c4a..919cdcaab 100644 --- a/database/migrations/2016_09_21_165554_update_servers_column_name.php +++ b/database/migrations/2016_09_21_165554_update_servers_column_name.php @@ -9,7 +9,7 @@ class UpdateServersColumnName extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->renameColumn('server', 'server_id'); @@ -19,7 +19,7 @@ class UpdateServersColumnName extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { $table->renameColumn('server_id', 'server'); diff --git a/database/migrations/2016_09_29_213518_rename_double_insurgency.php b/database/migrations/2016_09_29_213518_rename_double_insurgency.php index adb577754..5f21c7036 100644 --- a/database/migrations/2016_09_29_213518_rename_double_insurgency.php +++ b/database/migrations/2016_09_29_213518_rename_double_insurgency.php @@ -7,7 +7,7 @@ class RenameDoubleInsurgency extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::transaction(function () { $model = DB::table('service_options')->where('parent_service', 2)->where('id', 3)->where('name', 'Insurgency')->first(); @@ -21,7 +21,7 @@ class RenameDoubleInsurgency extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { } } diff --git a/database/migrations/2016_10_07_152117_build_api_log_table.php b/database/migrations/2016_10_07_152117_build_api_log_table.php index 08ea312dc..39356c5ba 100644 --- a/database/migrations/2016_10_07_152117_build_api_log_table.php +++ b/database/migrations/2016_10_07_152117_build_api_log_table.php @@ -9,7 +9,7 @@ class BuildApiLogTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('api_logs', function (Blueprint $table) { $table->increments('id'); @@ -28,7 +28,7 @@ class BuildApiLogTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('api_logs'); } diff --git a/database/migrations/2016_10_14_164802_update_api_keys.php b/database/migrations/2016_10_14_164802_update_api_keys.php index 56c3e8097..b43eef1b1 100644 --- a/database/migrations/2016_10_14_164802_update_api_keys.php +++ b/database/migrations/2016_10_14_164802_update_api_keys.php @@ -9,7 +9,7 @@ class UpdateApiKeys extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { $table->unsignedInteger('user')->after('id'); @@ -21,7 +21,7 @@ class UpdateApiKeys extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { $table->dropColumn('user'); diff --git a/database/migrations/2016_10_23_181719_update_misnamed_bungee.php b/database/migrations/2016_10_23_181719_update_misnamed_bungee.php index 70ec18b33..a9cf3a35c 100644 --- a/database/migrations/2016_10_23_181719_update_misnamed_bungee.php +++ b/database/migrations/2016_10_23_181719_update_misnamed_bungee.php @@ -7,7 +7,7 @@ class UpdateMisnamedBungee extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::table('service_variables')->select('env_variable')->where('env_variable', 'BUNGE_VERSION')->update([ 'env_variable' => 'BUNGEE_VERSION', @@ -17,7 +17,7 @@ class UpdateMisnamedBungee extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { } } diff --git a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php index 1412720c9..da0fc7c83 100644 --- a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php +++ b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php @@ -9,22 +9,21 @@ class AddForeignKeysServers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE servers - MODIFY COLUMN node INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN owner INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN allocation INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN service INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN `option` INT(10) UNSIGNED NOT NULL - '); - Schema::table('servers', function (Blueprint $table) { + $table->integer('node', false, true)->change(); + $table->integer('owner', false, true)->change(); + $table->integer('allocation', false, true)->change(); + $table->integer('service', false, true)->change(); + $table->integer('option', false, true)->change(); + $table->foreign('node')->references('id')->on('nodes'); $table->foreign('owner')->references('id')->on('users'); $table->foreign('allocation')->references('id')->on('allocations'); $table->foreign('service')->references('id')->on('services'); $table->foreign('option')->references('id')->on('service_options'); + $table->softDeletes(); }); } @@ -32,30 +31,31 @@ class AddForeignKeysServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign('servers_node_foreign'); - $table->dropForeign('servers_owner_foreign'); - $table->dropForeign('servers_allocation_foreign'); - $table->dropForeign('servers_service_foreign'); - $table->dropForeign('servers_option_foreign'); + $table->dropForeign(['node']); + $table->dropIndex(['node']); - $table->dropIndex('servers_node_foreign'); - $table->dropIndex('servers_owner_foreign'); - $table->dropIndex('servers_allocation_foreign'); - $table->dropIndex('servers_service_foreign'); - $table->dropIndex('servers_option_foreign'); + $table->dropForeign(['owner']); + $table->dropIndex(['owner']); + + $table->dropForeign(['allocation']); + $table->dropIndex(['allocation']); + + $table->dropForeign(['service']); + $table->dropIndex(['service']); + + $table->dropForeign(['option']); + $table->dropIndex(['option']); $table->dropColumn('deleted_at'); - }); - DB::statement('ALTER TABLE servers - MODIFY COLUMN node MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN owner MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN allocation MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN service MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN `option` MEDIUMINT(8) UNSIGNED NOT NULL - '); + $table->mediumInteger('node', false, true)->change(); + $table->mediumInteger('owner', false, true)->change(); + $table->mediumInteger('allocation', false, true)->change(); + $table->mediumInteger('service', false, true)->change(); + $table->mediumInteger('option', false, true)->change(); + }); } } diff --git a/database/migrations/2016_10_23_201624_add_foreign_allocations.php b/database/migrations/2016_10_23_201624_add_foreign_allocations.php index 0660081cb..7ae4b040d 100644 --- a/database/migrations/2016_10_23_201624_add_foreign_allocations.php +++ b/database/migrations/2016_10_23_201624_add_foreign_allocations.php @@ -1,5 +1,6 @@ integer('assigned_to', false, true)->nullable()->change(); + $table->integer('node', false, true)->nullable(false)->change(); $table->foreign('assigned_to')->references('id')->on('servers'); $table->foreign('node')->references('id')->on('nodes'); }); @@ -25,14 +23,17 @@ class AddForeignAllocations extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign('allocations_assigned_to_foreign'); - $table->dropForeign('allocations_node_foreign'); + $table->dropForeign(['assigned_to']); + $table->dropIndex(['assigned_to']); - $table->dropIndex('allocations_assigned_to_foreign'); - $table->dropIndex('allocations_node_foreign'); + $table->dropForeign(['node']); + $table->dropIndex(['node']); + + $table->mediumInteger('assigned_to', false, true)->nullable()->change(); + $table->mediumInteger('node', false, true)->nullable(false)->change(); }); DB::statement('ALTER TABLE allocations diff --git a/database/migrations/2016_10_23_202222_add_foreign_api_keys.php b/database/migrations/2016_10_23_202222_add_foreign_api_keys.php index 700342d74..44b11d0e5 100644 --- a/database/migrations/2016_10_23_202222_add_foreign_api_keys.php +++ b/database/migrations/2016_10_23_202222_add_foreign_api_keys.php @@ -9,7 +9,7 @@ class AddForeignApiKeys extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { $table->foreign('user')->references('id')->on('users'); @@ -19,11 +19,11 @@ class AddForeignApiKeys extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { - $table->dropForeign('api_keys_user_foreign'); - $table->dropIndex('api_keys_user_foreign'); + $table->dropForeign(['user']); + $table->dropIndex(['user']); }); } } diff --git a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php b/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php index d8eb3504d..2494eaba7 100644 --- a/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php +++ b/database/migrations/2016_10_23_202703_add_foreign_api_permissions.php @@ -9,11 +9,10 @@ class AddForeignApiPermissions extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE api_permissions MODIFY key_id INT(10) UNSIGNED NOT NULL'); - Schema::table('api_permissions', function (Blueprint $table) { + $table->integer('key_id', false, true)->nullable(false)->change(); $table->foreign('key_id')->references('id')->on('api_keys'); }); } @@ -21,13 +20,13 @@ class AddForeignApiPermissions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('api_permissions', function (Blueprint $table) { - $table->dropForeign('api_permissions_key_id_foreign'); - $table->dropIndex('api_permissions_key_id_foreign'); - }); + $table->dropForeign(['key_id']); + $table->dropIndex(['key_id']); - DB::statement('ALTER TABLE api_permissions MODIFY key_id MEDIUMINT(8) UNSIGNED NOT NULL'); + $table->mediumInteger('key_id', false, true)->nullable(false)->change(); + }); } } diff --git a/database/migrations/2016_10_23_202953_add_foreign_database_servers.php b/database/migrations/2016_10_23_202953_add_foreign_database_servers.php index 769b7daa3..78ee8264d 100644 --- a/database/migrations/2016_10_23_202953_add_foreign_database_servers.php +++ b/database/migrations/2016_10_23_202953_add_foreign_database_servers.php @@ -9,7 +9,7 @@ class AddForeignDatabaseServers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('database_servers', function (Blueprint $table) { $table->foreign('linked_node')->references('id')->on('nodes'); @@ -19,11 +19,11 @@ class AddForeignDatabaseServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('database_servers', function (Blueprint $table) { - $table->dropForeign('database_servers_linked_node_foreign'); - $table->dropIndex('database_servers_linked_node_foreign'); + $table->dropForeign(['linked_node']); + $table->dropIndex(['linked_node']); }); } } diff --git a/database/migrations/2016_10_23_203105_add_foreign_databases.php b/database/migrations/2016_10_23_203105_add_foreign_databases.php index be26e3cb0..bea43049b 100644 --- a/database/migrations/2016_10_23_203105_add_foreign_databases.php +++ b/database/migrations/2016_10_23_203105_add_foreign_databases.php @@ -9,7 +9,7 @@ class AddForeignDatabases extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->foreign('server_id')->references('id')->on('servers'); @@ -20,14 +20,14 @@ class AddForeignDatabases extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { - $table->dropForeign('databases_server_id_foreign'); - $table->dropForeign('databases_db_server_foreign'); + $table->dropForeign(['server_id']); + $table->dropIndex(['server_id']); - $table->dropIndex('databases_server_id_foreign'); - $table->dropIndex('databases_db_server_foreign'); + $table->dropForeign(['db_server']); + $table->dropIndex(['db_server']); }); } } diff --git a/database/migrations/2016_10_23_203335_add_foreign_nodes.php b/database/migrations/2016_10_23_203335_add_foreign_nodes.php index f861e0a7d..375189a7f 100644 --- a/database/migrations/2016_10_23_203335_add_foreign_nodes.php +++ b/database/migrations/2016_10_23_203335_add_foreign_nodes.php @@ -9,11 +9,10 @@ class AddForeignNodes extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE nodes MODIFY location INT(10) UNSIGNED NOT NULL'); - Schema::table('nodes', function (Blueprint $table) { + $table->integer('location', false, true)->nullable(false)->change(); $table->foreign('location')->references('id')->on('locations'); }); } @@ -21,13 +20,13 @@ class AddForeignNodes extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_foreign'); - $table->dropIndex('nodes_location_foreign'); - }); + $table->dropForeign(['location']); + $table->dropIndex(['location']); - DB::statement('ALTER TABLE nodes MODIFY location MEDIUMINT(10) UNSIGNED NOT NULL'); + $table->mediumInteger('location', false, true)->nullable(false)->change(); + }); } } diff --git a/database/migrations/2016_10_23_203522_add_foreign_permissions.php b/database/migrations/2016_10_23_203522_add_foreign_permissions.php index a43f0eacf..78bbf32a5 100644 --- a/database/migrations/2016_10_23_203522_add_foreign_permissions.php +++ b/database/migrations/2016_10_23_203522_add_foreign_permissions.php @@ -9,7 +9,7 @@ class AddForeignPermissions extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('permissions', function (Blueprint $table) { $table->foreign('user_id')->references('id')->on('users'); @@ -20,14 +20,14 @@ class AddForeignPermissions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign('permissions_user_id_foreign'); - $table->dropForeign('permissions_server_id_foreign'); + $table->dropForeign(['user_id']); + $table->dropIndex(['user_id']); - $table->dropIndex('permissions_user_id_foreign'); - $table->dropIndex('permissions_server_id_foreign'); + $table->dropForeign(['server_id']); + $table->dropIndex(['server_id']); }); } } diff --git a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php b/database/migrations/2016_10_23_203857_add_foreign_server_variables.php index b4720495d..3ccc3d183 100644 --- a/database/migrations/2016_10_23_203857_add_foreign_server_variables.php +++ b/database/migrations/2016_10_23_203857_add_foreign_server_variables.php @@ -9,14 +9,11 @@ class AddForeignServerVariables extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE server_variables - MODIFY COLUMN server_id INT(10) UNSIGNED NULL, - MODIFY COLUMN variable_id INT(10) UNSIGNED NOT NULL - '); - Schema::table('server_variables', function (Blueprint $table) { + $table->integer('server_id', false, true)->nullable()->change(); + $table->integer('variable_id', false, true)->nullable(false)->change(); $table->foreign('server_id')->references('id')->on('servers'); $table->foreign('variable_id')->references('id')->on('service_variables'); }); @@ -25,16 +22,13 @@ class AddForeignServerVariables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('server_variables', function (Blueprint $table) { $table->dropForeign(['server_id']); $table->dropForeign(['variable_id']); + $table->mediumInteger('server_id', false, true)->nullable()->change(); + $table->mediumInteger('variable_id', false, true)->nullable(false)->change(); }); - - DB::statement('ALTER TABLE server_variables - MODIFY COLUMN server_id MEDIUMINT(8) UNSIGNED NULL, - MODIFY COLUMN variable_id MEDIUMINT(8) UNSIGNED NOT NULL - '); } } diff --git a/database/migrations/2016_10_23_204157_add_foreign_service_options.php b/database/migrations/2016_10_23_204157_add_foreign_service_options.php index cb8c0e2e8..9f01905b7 100644 --- a/database/migrations/2016_10_23_204157_add_foreign_service_options.php +++ b/database/migrations/2016_10_23_204157_add_foreign_service_options.php @@ -9,11 +9,10 @@ class AddForeignServiceOptions extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE service_options MODIFY parent_service INT(10) UNSIGNED NOT NULL'); - Schema::table('service_options', function (Blueprint $table) { + $table->integer('parent_service', false, true)->change(); $table->foreign('parent_service')->references('id')->on('services'); }); } @@ -21,13 +20,13 @@ class AddForeignServiceOptions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('service_options_parent_service_foreign'); - $table->dropIndex('service_options_parent_service_foreign'); - }); + $table->dropForeign(['parent_service']); + $table->dropIndex(['parent_service']); - DB::statement('ALTER TABLE service_options MODIFY parent_service MEDIUMINT(8) UNSIGNED NOT NULL'); + $table->mediumInteger('parent_service', false, true)->change(); + }); } } diff --git a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php b/database/migrations/2016_10_23_204321_add_foreign_service_variables.php index 02bbc46f2..df998efaf 100644 --- a/database/migrations/2016_10_23_204321_add_foreign_service_variables.php +++ b/database/migrations/2016_10_23_204321_add_foreign_service_variables.php @@ -9,11 +9,10 @@ class AddForeignServiceVariables extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - DB::statement('ALTER TABLE service_variables MODIFY option_id INT(10) UNSIGNED NOT NULL'); - Schema::table('service_variables', function (Blueprint $table) { + $table->integer('option_id', false, true)->change(); $table->foreign('option_id')->references('id')->on('service_options'); }); } @@ -21,13 +20,13 @@ class AddForeignServiceVariables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_variables', function (Blueprint $table) { - $table->dropForeign('service_variables_option_id_foreign'); - $table->dropIndex('service_variables_option_id_foreign'); - }); + $table->dropForeign(['option_id']); + $table->dropIndex(['option_id']); - DB::statement('ALTER TABLE service_variables MODIFY option_id MEDIUMINT(8) UNSIGNED NOT NULL'); + $table->mediumInteger('option_id', false, true)->change(); + }); } } diff --git a/database/migrations/2016_10_23_204454_add_foreign_subusers.php b/database/migrations/2016_10_23_204454_add_foreign_subusers.php index b637c80ae..ff4bb95a3 100644 --- a/database/migrations/2016_10_23_204454_add_foreign_subusers.php +++ b/database/migrations/2016_10_23_204454_add_foreign_subusers.php @@ -9,7 +9,7 @@ class AddForeignSubusers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('subusers', function (Blueprint $table) { $table->foreign('user_id')->references('id')->on('users'); @@ -20,14 +20,14 @@ class AddForeignSubusers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('subusers', function (Blueprint $table) { - $table->dropForeign('subusers_user_id_foreign'); - $table->dropForeign('subusers_server_id_foreign'); + $table->dropForeign(['user_id']); + $table->dropIndex(['user_id']); - $table->dropIndex('subusers_user_id_foreign'); - $table->dropIndex('subusers_server_id_foreign'); + $table->dropForeign(['server_id']); + $table->dropIndex(['server_id']); }); } } diff --git a/database/migrations/2016_10_23_204610_add_foreign_tasks.php b/database/migrations/2016_10_23_204610_add_foreign_tasks.php index 18ea297e5..f32d89230 100644 --- a/database/migrations/2016_10_23_204610_add_foreign_tasks.php +++ b/database/migrations/2016_10_23_204610_add_foreign_tasks.php @@ -9,7 +9,7 @@ class AddForeignTasks extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('tasks', function (Blueprint $table) { $table->foreign('server')->references('id')->on('servers'); @@ -19,7 +19,7 @@ class AddForeignTasks extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('tasks', function (Blueprint $table) { $table->dropForeign(['server']); diff --git a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php b/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php index 1547e32cc..c5fff5523 100644 --- a/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php +++ b/database/migrations/2016_11_04_000949_add_ark_service_option_fixed.php @@ -7,7 +7,7 @@ class AddArkServiceOptionFixed extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::transaction(function () { $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); @@ -73,7 +73,7 @@ class AddArkServiceOptionFixed extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { DB::transaction(function () { $service = DB::table('services')->select('id')->where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('name', 'Source Engine')->first(); diff --git a/database/migrations/2016_11_11_220649_add_pack_support.php b/database/migrations/2016_11_11_220649_add_pack_support.php index b6fa0972b..8fd638ae6 100644 --- a/database/migrations/2016_11_11_220649_add_pack_support.php +++ b/database/migrations/2016_11_11_220649_add_pack_support.php @@ -9,7 +9,7 @@ class AddPackSupport extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('service_packs', function (Blueprint $table) { $table->increments('id'); @@ -29,7 +29,7 @@ class AddPackSupport extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::drop('service_packs'); } diff --git a/database/migrations/2016_11_11_231731_set_service_name_unique.php b/database/migrations/2016_11_11_231731_set_service_name_unique.php index 42b0f6953..261fdb356 100644 --- a/database/migrations/2016_11_11_231731_set_service_name_unique.php +++ b/database/migrations/2016_11_11_231731_set_service_name_unique.php @@ -9,7 +9,7 @@ class SetServiceNameUnique extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->unique('name'); @@ -19,7 +19,7 @@ class SetServiceNameUnique extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropUnique('services_name_unique'); diff --git a/database/migrations/2016_11_27_142519_add_pack_column.php b/database/migrations/2016_11_27_142519_add_pack_column.php index d520466a8..3911ecb41 100644 --- a/database/migrations/2016_11_27_142519_add_pack_column.php +++ b/database/migrations/2016_11_27_142519_add_pack_column.php @@ -9,7 +9,7 @@ class AddPackColumn extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('pack')->nullable()->after('option'); @@ -21,7 +21,7 @@ class AddPackColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropForeign(['pack']); diff --git a/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php b/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php index d2d14f4d0..c5136fe9e 100644 --- a/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php +++ b/database/migrations/2016_12_01_173018_add_configurable_upload_limit.php @@ -9,7 +9,7 @@ class AddConfigurableUploadLimit extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->unsignedInteger('upload_size')->after('disk_overallocate')->default(100); @@ -19,7 +19,7 @@ class AddConfigurableUploadLimit extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { $table->dropColumn('upload_size'); diff --git a/database/migrations/2016_12_02_185206_correct_service_variables.php b/database/migrations/2016_12_02_185206_correct_service_variables.php index e9c87989a..d94b3b78b 100644 --- a/database/migrations/2016_12_02_185206_correct_service_variables.php +++ b/database/migrations/2016_12_02_185206_correct_service_variables.php @@ -7,7 +7,7 @@ class CorrectServiceVariables extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::transaction(function () { // Modify Default Spigot Startup Line @@ -66,7 +66,7 @@ class CorrectServiceVariables extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { // do nothing } diff --git a/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php b/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php index 7cdf96807..35248d6bb 100644 --- a/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php +++ b/database/migrations/2017_01_03_150436_fix_misnamed_option_tag.php @@ -7,7 +7,7 @@ class FixMisnamedOptionTag extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::transaction(function () { DB::table('service_options')->where([ @@ -23,7 +23,7 @@ class FixMisnamedOptionTag extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { DB::table('service_options')->where([ ['name', 'Sponge (SpongeVanilla)'], diff --git a/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php b/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php index 77693c265..c4369f975 100644 --- a/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php +++ b/database/migrations/2017_01_07_154228_create_node_configuration_tokens_table.php @@ -9,7 +9,7 @@ class CreateNodeConfigurationTokensTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('node_configuration_tokens', function (Blueprint $table) { $table->increments('id'); @@ -24,7 +24,7 @@ class CreateNodeConfigurationTokensTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('node_configuration_tokens'); } diff --git a/database/migrations/2017_01_12_135449_add_more_user_data.php b/database/migrations/2017_01_12_135449_add_more_user_data.php index 0206040b5..82ae8c9e9 100644 --- a/database/migrations/2017_01_12_135449_add_more_user_data.php +++ b/database/migrations/2017_01_12_135449_add_more_user_data.php @@ -10,7 +10,7 @@ class AddMoreUserData extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->string('name_first')->after('email')->nullable(); @@ -34,7 +34,7 @@ class AddMoreUserData extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn('name_first'); diff --git a/database/migrations/2017_02_02_175548_UpdateColumnNames.php b/database/migrations/2017_02_02_175548_UpdateColumnNames.php index c88aa8de7..719513313 100644 --- a/database/migrations/2017_02_02_175548_UpdateColumnNames.php +++ b/database/migrations/2017_02_02_175548_UpdateColumnNames.php @@ -9,22 +9,15 @@ class UpdateColumnNames extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign('servers_node_foreign'); - $table->dropForeign('servers_owner_foreign'); - $table->dropForeign('servers_allocation_foreign'); - $table->dropForeign('servers_service_foreign'); - $table->dropForeign('servers_option_foreign'); - $table->dropForeign('servers_pack_foreign'); - - $table->dropIndex('servers_node_foreign'); - $table->dropIndex('servers_owner_foreign'); - $table->dropIndex('servers_allocation_foreign'); - $table->dropIndex('servers_service_foreign'); - $table->dropIndex('servers_option_foreign'); - $table->dropIndex('servers_pack_foreign'); + $table->dropForeign(['node']); + $table->dropForeign(['owner']); + $table->dropForeign(['allocation']); + $table->dropForeign(['service']); + $table->dropForeign(['option']); + $table->dropForeign(['pack']); $table->renameColumn('node', 'node_id'); $table->renameColumn('owner', 'owner_id'); @@ -47,14 +40,10 @@ class UpdateColumnNames extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { - $table->dropForeign(['node_id']); - $table->dropForeign(['owner_id']); - $table->dropForeign(['allocation_id']); - $table->dropForeign(['service_id']); - $table->dropForeign(['option_id']); + $table->dropForeign(['node_id', 'owner_id', 'allocation_id', 'service_id', 'option_id']); $table->renameColumn('node_id', 'node'); $table->renameColumn('owner_id', 'owner'); diff --git a/database/migrations/2017_02_03_140948_UpdateNodesTable.php b/database/migrations/2017_02_03_140948_UpdateNodesTable.php index 58ec63ef4..e797cc704 100644 --- a/database/migrations/2017_02_03_140948_UpdateNodesTable.php +++ b/database/migrations/2017_02_03_140948_UpdateNodesTable.php @@ -9,11 +9,10 @@ class UpdateNodesTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_foreign'); - $table->dropIndex('nodes_location_foreign'); + $table->dropForeign(['location']); $table->renameColumn('location', 'location_id'); $table->foreign('location_id')->references('id')->on('locations'); @@ -23,11 +22,10 @@ class UpdateNodesTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { - $table->dropForeign('nodes_location_id_foreign'); - $table->dropIndex('nodes_location_id_foreign'); + $table->dropForeign(['location_id']); $table->renameColumn('location_id', 'location'); $table->foreign('location')->references('id')->on('locations'); diff --git a/database/migrations/2017_02_03_155554_RenameColumns.php b/database/migrations/2017_02_03_155554_RenameColumns.php index 5f617abec..bd50e16be 100644 --- a/database/migrations/2017_02_03_155554_RenameColumns.php +++ b/database/migrations/2017_02_03_155554_RenameColumns.php @@ -9,13 +9,11 @@ class RenameColumns extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign('allocations_node_foreign'); - $table->dropForeign('allocations_assigned_to_foreign'); - $table->dropIndex('allocations_node_foreign'); - $table->dropIndex('allocations_assigned_to_foreign'); + $table->dropForeign(['node']); + $table->dropForeign(['assigned_to']); $table->renameColumn('node', 'node_id'); $table->renameColumn('assigned_to', 'server_id'); @@ -27,13 +25,13 @@ class RenameColumns extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { - $table->dropForeign('allocations_node_id_foreign'); - $table->dropForeign('allocations_server_id_foreign'); - $table->dropIndex('allocations_node_id_foreign'); - $table->dropIndex('allocations_server_id_foreign'); + $table->dropForeign(['node_id']); + $table->dropForeign(['server_id']); + $table->dropIndex(['node_id']); + $table->dropIndex(['server_id']); $table->renameColumn('node_id', 'node'); $table->renameColumn('server_id', 'assigned_to'); diff --git a/database/migrations/2017_02_05_164123_AdjustColumnNames.php b/database/migrations/2017_02_05_164123_AdjustColumnNames.php index c7688f056..51c8818c7 100644 --- a/database/migrations/2017_02_05_164123_AdjustColumnNames.php +++ b/database/migrations/2017_02_05_164123_AdjustColumnNames.php @@ -9,11 +9,10 @@ class AdjustColumnNames extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('service_options_parent_service_foreign'); - $table->dropIndex('service_options_parent_service_foreign'); + $table->dropForeign(['parent_service']); $table->renameColumn('parent_service', 'service_id'); $table->foreign('service_id')->references('id')->on('services'); @@ -23,11 +22,11 @@ class AdjustColumnNames extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { - $table->dropForeign('service_options_service_id_foreign'); - $table->dropIndex('service_options_service_id_foreign'); + $table->dropForeign(['service_id']); + $table->dropIndex(['service_id']); $table->renameColumn('service_id', 'parent_service'); $table->foreign('parent_service')->references('id')->on('services'); diff --git a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php b/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php index 6f86b3b6e..69dc33dda 100644 --- a/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php +++ b/database/migrations/2017_02_05_164516_AdjustColumnNamesForServicePacks.php @@ -9,11 +9,10 @@ class AdjustColumnNamesForServicePacks extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_packs', function (Blueprint $table) { - $table->dropForeign('service_packs_option_foreign'); - $table->dropIndex('service_packs_option_foreign'); + $table->dropForeign(['option']); $table->renameColumn('option', 'option_id'); $table->foreign('option_id')->references('id')->on('service_options'); @@ -23,11 +22,11 @@ class AdjustColumnNamesForServicePacks extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_packs', function (Blueprint $table) { - $table->dropForeign('service_packs_option_id_foreign'); - $table->dropIndex('service_packs_option_id_foreign'); + $table->dropForeign(['option_id']); + $table->dropIndex(['option_id']); $table->renameColumn('option_id', 'option'); $table->foreign('option')->references('id')->on('service_options'); diff --git a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php index 45efce83a..bf6469506 100644 --- a/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php +++ b/database/migrations/2017_02_09_174834_SetupPermissionsPivotTable.php @@ -11,7 +11,7 @@ class SetupPermissionsPivotTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('permissions', function (Blueprint $table) { $table->unsignedInteger('subuser_id')->after('id'); @@ -19,17 +19,15 @@ class SetupPermissionsPivotTable extends Migration DB::transaction(function () { foreach (Subuser::all() as &$subuser) { - Permission::where('user_id', $subuser->user_id)->where('server_id', $subuser->server_id)->update([ + Permission::query()->where('user_id', $subuser->user_id)->where('server_id', $subuser->server_id)->update([ 'subuser_id' => $subuser->id, ]); } }); Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign('permissions_server_id_foreign'); - $table->dropIndex('permissions_server_id_foreign'); - $table->dropForeign('permissions_user_id_foreign'); - $table->dropIndex('permissions_user_id_foreign'); + $table->dropForeign(['server_id']); + $table->dropForeign(['user_id']); $table->dropColumn('server_id'); $table->dropColumn('user_id'); @@ -42,7 +40,7 @@ class SetupPermissionsPivotTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('permissions', function (Blueprint $table) { $table->unsignedInteger('server_id')->after('subuser_id'); @@ -52,7 +50,7 @@ class SetupPermissionsPivotTable extends Migration DB::transaction(function () { foreach (Subuser::all() as &$subuser) { - Permission::where('subuser_id', $subuser->id)->update([ + Permission::query()->where('subuser_id', $subuser->id)->update([ 'user_id' => $subuser->user_id, 'server_id' => $subuser->server_id, ]); @@ -60,8 +58,8 @@ class SetupPermissionsPivotTable extends Migration }); Schema::table('permissions', function (Blueprint $table) { - $table->dropForeign('permissions_subuser_id_foreign'); - $table->dropIndex('permissions_subuser_id_foreign'); + $table->dropForeign(['subuser_id']); + $table->dropIndex(['subuser_id']); $table->dropColumn('subuser_id'); $table->foreign('server_id')->references('id')->on('servers'); diff --git a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php b/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php index 8b541d941..8ae28c2c9 100644 --- a/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php +++ b/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php @@ -9,10 +9,10 @@ class UpdateAPIKeyColumnNames extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { - $table->dropForeign('api_keys_user_foreign')->dropIndex('api_keys_user_foreign'); + $table->dropForeign(['user']); $table->renameColumn('user', 'user_id'); $table->foreign('user_id')->references('id')->on('users'); @@ -22,10 +22,10 @@ class UpdateAPIKeyColumnNames extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { - $table->dropForeign('api_keys_user_id_foreign')->dropIndex('api_keys_user_id_foreign'); + $table->dropForeign(['user_id']); $table->renameColumn('user_id', 'user'); $table->foreign('user')->references('id')->on('users'); diff --git a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php b/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php index 4f27346fa..aab6c2b95 100644 --- a/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php +++ b/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php @@ -9,7 +9,7 @@ class UpdateNodeConfigTokensColumns extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('node_configuration_tokens', function (Blueprint $table) { $table->dropForeign(['node']); @@ -23,7 +23,7 @@ class UpdateNodeConfigTokensColumns extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('node_configuration_tokens', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php index 6792f265a..d697a3315 100644 --- a/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php +++ b/database/migrations/2017_03_05_212803_DeleteServiceExecutableOption.php @@ -9,7 +9,7 @@ class DeleteServiceExecutableOption extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->renameColumn('file', 'folder'); @@ -22,7 +22,7 @@ class DeleteServiceExecutableOption extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->string('executable')->after('folder'); diff --git a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php b/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php index 385004fa4..06c04694c 100644 --- a/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php +++ b/database/migrations/2017_03_10_162934_AddNewServiceOptionsColumns.php @@ -9,7 +9,7 @@ class AddNewServiceOptionsColumns extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropColumn('executable'); @@ -27,7 +27,7 @@ class AddNewServiceOptionsColumns extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropForeign(['config_from']); diff --git a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php index 7cf5707c4..40aef1524 100644 --- a/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php +++ b/database/migrations/2017_03_10_173607_MigrateToNewServiceSystem.php @@ -7,7 +7,7 @@ class MigrateToNewServiceSystem extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::transaction(function () { $service = DB::table('services')->where('author', config('pterodactyl.service.core'))->where('folder', 'srcds')->first(); @@ -32,7 +32,7 @@ class MigrateToNewServiceSystem extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { // Not doing reversals right now... } diff --git a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php index 21fa51465..3e7e5f18b 100644 --- a/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php +++ b/database/migrations/2017_03_11_215455_ChangeServiceVariablesValidationRules.php @@ -9,7 +9,7 @@ class ChangeServiceVariablesValidationRules extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_variables', function (Blueprint $table) { $table->renameColumn('regex', 'rules'); @@ -30,7 +30,7 @@ class ChangeServiceVariablesValidationRules extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_variables', function (Blueprint $table) { $table->renameColumn('rules', 'regex'); diff --git a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php b/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php index 3628ba7a4..26599246c 100644 --- a/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php +++ b/database/migrations/2017_03_12_150648_MoveFunctionsFromFileToDatabase.php @@ -85,7 +85,7 @@ EOF; /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->text('index_file')->after('startup'); @@ -105,7 +105,7 @@ EOF; /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('index_file'); diff --git a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php b/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php index d01012e41..f73befdba 100644 --- a/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php +++ b/database/migrations/2017_03_14_175631_RenameServicePacksToSingluarPacks.php @@ -9,7 +9,7 @@ class RenameServicePacksToSingluarPacks extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_packs', function (Blueprint $table) { $table->dropForeign(['option_id']); @@ -25,7 +25,7 @@ class RenameServicePacksToSingluarPacks extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('packs', function (Blueprint $table) { $table->dropForeign(['option_id']); diff --git a/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php b/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php index b1a8ee3a0..b396954e0 100644 --- a/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php +++ b/database/migrations/2017_03_14_200326_AddLockedStatusToTable.php @@ -9,7 +9,7 @@ class AddLockedStatusToTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('packs', function (Blueprint $table) { $table->boolean('locked')->default(false)->after('visible'); @@ -19,7 +19,7 @@ class AddLockedStatusToTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('packs', function (Blueprint $table) { $table->dropColumn('locked'); diff --git a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php b/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php index a7166df9e..c973faa55 100644 --- a/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php +++ b/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php @@ -9,7 +9,7 @@ class ReOrganizeDatabaseServersToDatabaseHost extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('database_servers', function (Blueprint $table) { $table->dropForeign(['linked_node']); @@ -27,7 +27,7 @@ class ReOrganizeDatabaseServersToDatabaseHost extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('database_hosts', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php b/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php index bc6fb45c7..2b689c481 100644 --- a/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php +++ b/database/migrations/2017_03_16_181515_CleanupDatabasesDatabase.php @@ -9,7 +9,7 @@ class CleanupDatabasesDatabase extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->dropForeign(['db_server']); @@ -23,7 +23,7 @@ class CleanupDatabasesDatabase extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { $table->dropForeign(['database_host_id']); diff --git a/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php b/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php index 3f26a1e34..bdd1f1a54 100644 --- a/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php +++ b/database/migrations/2017_03_18_204953_AddForeignKeyToPacks.php @@ -9,7 +9,7 @@ class AddForeignKeyToPacks extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->foreign('pack_id')->references('id')->on('packs'); @@ -19,7 +19,7 @@ class AddForeignKeyToPacks extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropForeign(['pack_id']); diff --git a/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php b/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php index e8ebcb20d..69d044582 100644 --- a/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php +++ b/database/migrations/2017_03_31_221948_AddServerDescriptionColumn.php @@ -9,7 +9,7 @@ class AddServerDescriptionColumn extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->text('description')->after('name'); @@ -19,7 +19,7 @@ class AddServerDescriptionColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('description'); diff --git a/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php b/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php index 3cd08f1a9..0c193192b 100644 --- a/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php +++ b/database/migrations/2017_04_02_163232_DropDeletedAtColumnFromServers.php @@ -9,7 +9,7 @@ class DropDeletedAtColumnFromServers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('deleted_at'); @@ -19,7 +19,7 @@ class DropDeletedAtColumnFromServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->timestamp('deleted_at')->nullable(); diff --git a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php b/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php index d069e1ba1..f5e48cfea 100644 --- a/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php +++ b/database/migrations/2017_04_15_125021_UpgradeTaskSystem.php @@ -10,7 +10,7 @@ class UpgradeTaskSystem extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('tasks', function (Blueprint $table) { $table->dropForeign(['server']); @@ -33,7 +33,7 @@ class UpgradeTaskSystem extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('tasks', function (Blueprint $table) { // $table->dropForeign(['server_id']); diff --git a/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php b/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php index ba2f57c41..96a85be92 100644 --- a/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php +++ b/database/migrations/2017_04_20_171943_AddScriptsToServiceOptions.php @@ -9,7 +9,7 @@ class AddScriptsToServiceOptions extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { $table->text('script_install')->after('startup')->nullable(); @@ -22,7 +22,7 @@ class AddScriptsToServiceOptions extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropColumn('script_install'); diff --git a/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php b/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php index 2bc8f27b3..970b41773 100644 --- a/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php +++ b/database/migrations/2017_04_21_151432_AddServiceScriptTrackingToServers.php @@ -9,7 +9,7 @@ class AddServiceScriptTrackingToServers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->boolean('skip_scripts')->default(false)->after('description'); @@ -19,7 +19,7 @@ class AddServiceScriptTrackingToServers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('skip_scripts'); diff --git a/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php b/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php index 514d17e1c..8888600fb 100644 --- a/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php +++ b/database/migrations/2017_04_27_145300_AddCopyScriptFromColumn.php @@ -9,7 +9,7 @@ class AddCopyScriptFromColumn extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { $table->unsignedInteger('copy_script_from')->nullable()->after('script_container'); @@ -21,7 +21,7 @@ class AddCopyScriptFromColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropForeign(['copy_script_from']); diff --git a/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php b/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php index aa5e04498..96bb9aec5 100644 --- a/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php +++ b/database/migrations/2017_04_27_223629_AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy.php @@ -9,7 +9,7 @@ class AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->boolean('behind_proxy')->after('scheme')->default(false); @@ -19,7 +19,7 @@ class AddAbilityToDefineConnectionOverSSLWithDaemonBehindProxy extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { $table->dropColumn('behind_proxy'); diff --git a/database/migrations/2017_05_01_141528_DeleteDownloadTable.php b/database/migrations/2017_05_01_141528_DeleteDownloadTable.php index 7dcae3c6f..967c12615 100644 --- a/database/migrations/2017_05_01_141528_DeleteDownloadTable.php +++ b/database/migrations/2017_05_01_141528_DeleteDownloadTable.php @@ -9,7 +9,7 @@ class DeleteDownloadTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::dropIfExists('downloads'); } @@ -17,7 +17,7 @@ class DeleteDownloadTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::create('downloads', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php b/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php index 90c8c4b1e..d230bc19a 100644 --- a/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php +++ b/database/migrations/2017_05_01_141559_DeleteNodeConfigurationTable.php @@ -9,7 +9,7 @@ class DeleteNodeConfigurationTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::dropIfExists('node_configuration_tokens'); } @@ -17,7 +17,7 @@ class DeleteNodeConfigurationTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::create('node_configuration_tokens', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2017_06_10_152951_add_external_id_to_users.php b/database/migrations/2017_06_10_152951_add_external_id_to_users.php index 9ce5057e8..bccfb43fd 100644 --- a/database/migrations/2017_06_10_152951_add_external_id_to_users.php +++ b/database/migrations/2017_06_10_152951_add_external_id_to_users.php @@ -9,7 +9,7 @@ class AddExternalIdToUsers extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->unsignedInteger('external_id')->after('id')->nullable()->unique(); @@ -19,7 +19,7 @@ class AddExternalIdToUsers extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn('external_id'); diff --git a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php b/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php index a089ab4db..6f36d0e05 100644 --- a/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php +++ b/database/migrations/2017_06_25_133923_ChangeForeignKeyToBeOnCascadeDelete.php @@ -9,7 +9,7 @@ class ChangeForeignKeyToBeOnCascadeDelete extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('api_permissions', function (Blueprint $table) { $table->dropForeign(['key_id']); @@ -21,7 +21,7 @@ class ChangeForeignKeyToBeOnCascadeDelete extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('api_permissions', function (Blueprint $table) { $table->dropForeign(['key_id']); diff --git a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php b/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php index 0bfc7d527..10058c8cc 100644 --- a/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php +++ b/database/migrations/2017_07_08_152806_ChangeUserPermissionsToDeleteOnUserDeletion.php @@ -9,7 +9,7 @@ class ChangeUserPermissionsToDeleteOnUserDeletion extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('permissions', function (Blueprint $table) { $table->dropForeign(['subuser_id']); @@ -29,7 +29,7 @@ class ChangeUserPermissionsToDeleteOnUserDeletion extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('subusers', function (Blueprint $table) { $table->dropForeign(['user_id']); diff --git a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php b/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php index fb156ba8c..8ac6eccec 100644 --- a/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php +++ b/database/migrations/2017_07_08_154416_SetAllocationToReferenceNullOnServerDelete.php @@ -9,7 +9,7 @@ class SetAllocationToReferenceNullOnServerDelete extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropForeign(['server_id']); @@ -21,7 +21,7 @@ class SetAllocationToReferenceNullOnServerDelete extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropForeign(['server_id']); diff --git a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php b/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php index 5ae9a29f9..ca5a4623f 100644 --- a/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php +++ b/database/migrations/2017_07_08_154650_CascadeDeletionWhenAServerOrVariableIsDeleted.php @@ -9,7 +9,7 @@ class CascadeDeletionWhenAServerOrVariableIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('server_variables', function (Blueprint $table) { $table->dropForeign(['server_id']); @@ -23,7 +23,7 @@ class CascadeDeletionWhenAServerOrVariableIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('server_variables', function (Blueprint $table) { $table->dropForeign(['server_id']); diff --git a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php b/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php index 89e110228..cf0a4bba1 100644 --- a/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php +++ b/database/migrations/2017_07_24_194433_DeleteTaskWhenParentServerIsDeleted.php @@ -9,7 +9,7 @@ class DeleteTaskWhenParentServerIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('tasks', function (Blueprint $table) { $table->dropForeign(['server_id']); @@ -21,7 +21,7 @@ class DeleteTaskWhenParentServerIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { } } diff --git a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php b/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php index a33b78af6..0eabe77db 100644 --- a/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php +++ b/database/migrations/2017_08_05_115800_CascadeNullValuesForDatabaseHostWhenNodeIsDeleted.php @@ -9,7 +9,7 @@ class CascadeNullValuesForDatabaseHostWhenNodeIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('database_hosts', function (Blueprint $table) { $table->dropForeign(['node_id']); @@ -20,7 +20,7 @@ class CascadeNullValuesForDatabaseHostWhenNodeIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('database_hosts', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php index 77b7f984c..3fb457dc4 100644 --- a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php +++ b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php @@ -9,7 +9,7 @@ class AllowNegativeValuesForOverallocation extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->integer('disk_overallocate')->default(0)->nullable(false)->change(); @@ -20,10 +20,10 @@ class AllowNegativeValuesForOverallocation extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { - DB::statement('ALTER TABLE nodes MODIFY disk_overallocate MEDIUMINT UNSIGNED NULL, + DB::statement('ALTER TABLE nodes MODIFY disk_overallocate MEDIUMINT UNSIGNED NULL, MODIFY memory_overallocate MEDIUMINT UNSIGNED NULL'); }); } diff --git a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php index f7aab7c04..f2d8ad9bf 100644 --- a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php +++ b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php @@ -9,7 +9,7 @@ class SetAllocationUnqiueUsingMultipleFields extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('allocations', function (Blueprint $table) { $table->unique(['node_id', 'ip', 'port']); @@ -19,7 +19,7 @@ class SetAllocationUnqiueUsingMultipleFields extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php b/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php index 074f872e0..fbea750bc 100644 --- a/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php +++ b/database/migrations/2017_08_15_214555_CascadeDeletionWhenAParentServiceIsDeleted.php @@ -9,7 +9,7 @@ class CascadeDeletionWhenAParentServiceIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropForeign(['service_id']); @@ -21,7 +21,7 @@ class CascadeDeletionWhenAParentServiceIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropForeign(['service_id']); diff --git a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php b/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php index 1b8f1a567..7c59d801e 100644 --- a/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php +++ b/database/migrations/2017_08_18_215428_RemovePackWhenParentServiceOptionIsDeleted.php @@ -9,7 +9,7 @@ class RemovePackWhenParentServiceOptionIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('packs', function (Blueprint $table) { $table->dropForeign(['option_id']); @@ -21,7 +21,7 @@ class RemovePackWhenParentServiceOptionIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('packs', function (Blueprint $table) { $table->dropForeign(['option_id']); diff --git a/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php b/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php index 12eada73c..14f60b3b6 100644 --- a/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php +++ b/database/migrations/2017_09_10_225749_RenameTasksTableForStructureRefactor.php @@ -8,7 +8,7 @@ class RenameTasksTableForStructureRefactor extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::rename('tasks', 'tasks_old'); } @@ -16,7 +16,7 @@ class RenameTasksTableForStructureRefactor extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::rename('tasks_old', 'tasks'); } diff --git a/database/migrations/2017_09_10_225941_CreateSchedulesTable.php b/database/migrations/2017_09_10_225941_CreateSchedulesTable.php index 3d5baa6d3..588f48c8f 100644 --- a/database/migrations/2017_09_10_225941_CreateSchedulesTable.php +++ b/database/migrations/2017_09_10_225941_CreateSchedulesTable.php @@ -9,7 +9,7 @@ class CreateSchedulesTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('schedules', function (Blueprint $table) { $table->increments('id'); @@ -32,7 +32,7 @@ class CreateSchedulesTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('schedules'); } diff --git a/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php b/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php index 9c225a834..969c15361 100644 --- a/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php +++ b/database/migrations/2017_09_10_230309_CreateNewTasksTableForSchedules.php @@ -9,7 +9,7 @@ class CreateNewTasksTableForSchedules extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('tasks', function (Blueprint $table) { $table->increments('id'); @@ -29,7 +29,7 @@ class CreateNewTasksTableForSchedules extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('tasks'); } diff --git a/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php b/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php index 2a20ef10e..4656e272e 100644 --- a/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php +++ b/database/migrations/2017_09_11_002938_TransferOldTasksToNewScheduler.php @@ -2,6 +2,7 @@ use Carbon\Carbon; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; @@ -10,40 +11,40 @@ class TransferOldTasksToNewScheduler extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { - $tasks = DB::table('tasks_old')->get(); + DB::transaction(function () { + $tasks = DB::table('tasks_old')->get(); - DB::beginTransaction(); - $tasks->each(function ($task) { - $schedule = DB::table('schedules')->insertGetId([ - 'server_id' => $task->server_id, - 'name' => null, - 'cron_day_of_week' => $task->day_of_week, - 'cron_day_of_month' => $task->day_of_month, - 'cron_hour' => $task->hour, - 'cron_minute' => $task->minute, - 'is_active' => (bool) $task->active, - 'is_processing' => false, - 'last_run_at' => $task->last_run, - 'next_run_at' => $task->next_run, - 'created_at' => $task->created_at, - 'updated_at' => Carbon::now()->toDateTimeString(), - ]); + $tasks->each(function ($task) { + $schedule = DB::table('schedules')->insertGetId([ + 'server_id' => $task->server_id, + 'name' => null, + 'cron_day_of_week' => $task->day_of_week, + 'cron_day_of_month' => $task->day_of_month, + 'cron_hour' => $task->hour, + 'cron_minute' => $task->minute, + 'is_active' => (bool) $task->active, + 'is_processing' => false, + 'last_run_at' => $task->last_run, + 'next_run_at' => $task->next_run, + 'created_at' => $task->created_at, + 'updated_at' => Carbon::now()->toDateTimeString(), + ]); - DB::table('tasks')->insert([ - 'schedule_id' => $schedule, - 'sequence_id' => 1, - 'action' => $task->action, - 'payload' => $task->data, - 'time_offset' => 0, - 'is_queued' => false, - 'updated_at' => Carbon::now()->toDateTimeString(), - 'created_at' => Carbon::now()->toDateTimeString(), - ]); + DB::table('tasks')->insert([ + 'schedule_id' => $schedule, + 'sequence_id' => 1, + 'action' => $task->action, + 'payload' => $task->data, + 'time_offset' => 0, + 'is_queued' => false, + 'updated_at' => Carbon::now()->toDateTimeString(), + 'created_at' => Carbon::now()->toDateTimeString(), + ]); - DB::table('tasks_old')->delete($task->id); - DB::commit(); + DB::table('tasks_old')->delete($task->id); + }); }); Schema::dropIfExists('tasks_old'); @@ -52,7 +53,7 @@ class TransferOldTasksToNewScheduler extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::create('tasks_old', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php index ba3a8bac0..7c0c57447 100644 --- a/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php +++ b/database/migrations/2017_09_13_211810_UpdateOldPermissionsToPointToNewScheduleSystem.php @@ -8,7 +8,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { $permissions = DB::table('permissions')->where('permission', 'like', '%-task%')->get(); foreach ($permissions as $record) { @@ -26,7 +26,7 @@ class UpdateOldPermissionsToPointToNewScheduleSystem extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { $permissions = DB::table('permissions')->where('permission', 'like', '%-schedule%')->get(); foreach ($permissions as $record) { diff --git a/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php b/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php index cfbfc88b0..64ff02666 100644 --- a/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php +++ b/database/migrations/2017_09_23_170933_CreateDaemonKeysTable.php @@ -9,7 +9,7 @@ class CreateDaemonKeysTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('daemon_keys', function (Blueprint $table) { $table->increments('id'); @@ -28,7 +28,7 @@ class CreateDaemonKeysTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('daemon_keys'); } diff --git a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php index 84cb2d92b..b284905a0 100644 --- a/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php +++ b/database/migrations/2017_09_23_173628_RemoveDaemonSecretFromServersTable.php @@ -12,7 +12,7 @@ class RemoveDaemonSecretFromServersTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { $inserts = []; @@ -41,7 +41,7 @@ class RemoveDaemonSecretFromServersTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->char('daemonSecret', 36)->after('startup')->unique(); diff --git a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php index d4d2dd695..9ea90cff2 100644 --- a/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php +++ b/database/migrations/2017_09_23_185022_RemoveDaemonSecretFromSubusersTable.php @@ -1,6 +1,7 @@ get(); @@ -39,7 +40,7 @@ class RemoveDaemonSecretFromSubusersTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('subusers', function (Blueprint $table) { $table->char('daemonSecret', 36)->after('server_id'); diff --git a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php index dffa7687a..aae62921a 100644 --- a/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php +++ b/database/migrations/2017_10_02_202000_ChangeServicesToUseAMoreUniqueIdentifier.php @@ -11,7 +11,7 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('services', function (Blueprint $table) { $table->dropUnique(['name']); @@ -39,7 +39,7 @@ class ChangeServicesToUseAMoreUniqueIdentifier extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('services', function (Blueprint $table) { $table->dropColumn('uuid'); diff --git a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php b/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php index 5c9df79a5..679a8b5e0 100644 --- a/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php +++ b/database/migrations/2017_10_02_202007_ChangeToABetterUniqueServiceConfiguration.php @@ -11,7 +11,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_options', function (Blueprint $table) { $table->char('uuid', 36)->after('id'); @@ -40,7 +40,7 @@ class ChangeToABetterUniqueServiceConfiguration extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_options', function (Blueprint $table) { $table->dropColumn('uuid'); diff --git a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php index 3b19e3d99..9a64abf07 100644 --- a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php +++ b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php @@ -9,7 +9,7 @@ class CascadeDeletionWhenServiceOptionIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('service_variables', function (Blueprint $table) { $table->dropForeign(['option_id']); @@ -21,7 +21,7 @@ class CascadeDeletionWhenServiceOptionIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('service_variables', function (Blueprint $table) { $table->dropForeign(['option_id']); diff --git a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php index e7b70136c..cea7460e6 100644 --- a/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php +++ b/database/migrations/2017_10_06_214026_ServicesToNestsConversion.php @@ -1,5 +1,6 @@ dropUnique(['username']); @@ -22,7 +22,7 @@ class RemoveLegacySFTPInformation extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->string('username')->nullable()->after('image')->unique(); diff --git a/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php b/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php index b90b150bd..b02e326c6 100644 --- a/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php +++ b/database/migrations/2017_11_11_161922_Add2FaLastAuthorizationTimeColumn.php @@ -12,7 +12,7 @@ class Add2FaLastAuthorizationTimeColumn extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->text('totp_secret')->nullable()->change(); @@ -36,7 +36,7 @@ class Add2FaLastAuthorizationTimeColumn extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { DB::transaction(function () { DB::table('users')->get()->each(function ($user) { diff --git a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php b/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php index c2947ee07..229827dbc 100644 --- a/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php +++ b/database/migrations/2017_11_19_122708_MigratePubPrivFormatToSingleKey.php @@ -1,5 +1,6 @@ get()->each(function ($item) { try { $decrypted = Crypt::decrypt($item->secret); - } catch (DecryptException $exception) { + } catch (DecryptException) { $decrypted = str_random(32); } finally { DB::table('api_keys')->where('id', $item->id)->update([ @@ -30,27 +31,41 @@ class MigratePubPrivFormatToSingleKey extends Migration Schema::table('api_keys', function (Blueprint $table) { $table->dropColumn('public'); - $table->string('secret', 32)->change(); + $table->renameColumn('secret', 'token'); }); - DB::statement('ALTER TABLE `api_keys` CHANGE `secret` `token` CHAR(32) NOT NULL, ADD UNIQUE INDEX `api_keys_token_unique` (`token`(32))'); + Schema::table('api_keys', function (Blueprint $table) { + $table->char('token', 32)->change(); + $table->unique('token'); + }); } /** * Reverse the migrations. */ - public function down() + public function down(): void { - DB::statement('ALTER TABLE `api_keys` CHANGE `token` `secret` TEXT, DROP INDEX `api_keys_token_unique`'); + Schema::table('api_keys', function (Blueprint $table) { + $table->dropUnique(['token']); + $table->renameColumn('token', 'secret'); + }); Schema::table('api_keys', function (Blueprint $table) { + $table->dropUnique('token'); + $table->text('token')->change(); + }); + + Schema::table('api_keys', function (Blueprint $table) { + $table->renameColumn('token', 'secret'); + + $table->text('secret')->nullable()->change(); $table->char('public', 16)->after('user_id'); }); DB::transaction(function () { DB::table('api_keys')->get()->each(function ($item) { DB::table('api_keys')->where('id', $item->id)->update([ - 'public' => str_random(16), + 'public' => Str::random(16), 'secret' => Crypt::encrypt($item->secret), ]); }); diff --git a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php b/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php index d28109598..9a0cc9114 100644 --- a/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php +++ b/database/migrations/2017_12_04_184012_DropAllocationsWhenNodeIsDeleted.php @@ -9,7 +9,7 @@ class DropAllocationsWhenNodeIsDeleted extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropForeign(['node_id']); @@ -21,7 +21,7 @@ class DropAllocationsWhenNodeIsDeleted extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php b/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php index 1bdaf6477..8d639a37a 100644 --- a/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php +++ b/database/migrations/2017_12_12_220426_MigrateSettingsTableToNewFormat.php @@ -10,7 +10,7 @@ class MigrateSettingsTableToNewFormat extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { DB::table('settings')->truncate(); Schema::table('settings', function (Blueprint $table) { @@ -21,7 +21,7 @@ class MigrateSettingsTableToNewFormat extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::table('settings', function (Blueprint $table) { $table->dropColumn('id'); diff --git a/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php b/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php index 8f9938da1..7ccae5d61 100644 --- a/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php +++ b/database/migrations/2018_01_01_122821_AllowNegativeValuesForServerSwap.php @@ -8,10 +8,8 @@ class AllowNegativeValuesForServerSwap extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->integer('swap')->change(); @@ -20,10 +18,8 @@ class AllowNegativeValuesForServerSwap extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('swap')->change(); diff --git a/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php b/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php index adc6d2648..118a422f4 100644 --- a/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php +++ b/database/migrations/2018_01_11_213943_AddApiKeyPermissionColumns.php @@ -8,10 +8,8 @@ class AddApiKeyPermissionColumns extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::dropIfExists('api_permissions'); @@ -31,10 +29,8 @@ class AddApiKeyPermissionColumns extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::create('api_permissions', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php b/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php index 1d36b3648..d7e33210d 100644 --- a/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php +++ b/database/migrations/2018_01_13_142012_SetupTableForKeyEncryption.php @@ -9,12 +9,10 @@ class SetupTableForKeyEncryption extends Migration /** * Run the migrations. * - * @return void - * * @throws \Exception * @throws \Throwable */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { $table->char('identifier', 16)->nullable()->unique()->after('user_id'); @@ -29,12 +27,10 @@ class SetupTableForKeyEncryption extends Migration /** * Reverse the migrations. * - * @return void - * * @throws \Exception * @throws \Throwable */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { $table->dropColumn('identifier'); diff --git a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php b/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php index e0f86b9de..f78f7a5d1 100644 --- a/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php +++ b/database/migrations/2018_01_13_145209_AddLastUsedAtColumn.php @@ -8,10 +8,8 @@ class AddLastUsedAtColumn extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { $table->unsignedTinyInteger('key_type')->after('user_id')->default(0); @@ -28,10 +26,8 @@ class AddLastUsedAtColumn extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { $table->timestamp('expires_at')->after('memo')->nullable(); diff --git a/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php b/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php index 6a4a04e7d..6166f016e 100644 --- a/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php +++ b/database/migrations/2018_02_04_145617_AllowTextInUserExternalId.php @@ -8,10 +8,8 @@ class AllowTextInUserExternalId extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->string('external_id')->nullable()->change(); @@ -20,10 +18,8 @@ class AllowTextInUserExternalId extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->unsignedInteger('external_id')->change(); diff --git a/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php b/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php index b587cdcb0..64dbaf0dc 100644 --- a/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php +++ b/database/migrations/2018_02_10_151150_remove_unique_index_on_external_id_column.php @@ -8,10 +8,8 @@ class RemoveUniqueIndexOnExternalIdColumn extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->dropUnique(['external_id']); @@ -20,10 +18,8 @@ class RemoveUniqueIndexOnExternalIdColumn extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->unique(['external_id']); diff --git a/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php b/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php index bff7bbfb0..99f1db454 100644 --- a/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php +++ b/database/migrations/2018_02_17_134254_ensure_unique_allocation_id_on_servers_table.php @@ -8,10 +8,8 @@ class EnsureUniqueAllocationIdOnServersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->unique(['allocation_id']); @@ -20,10 +18,8 @@ class EnsureUniqueAllocationIdOnServersTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropForeign(['allocation_id']); diff --git a/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php b/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php index 2c8af99e2..c7d0f8fd4 100644 --- a/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php +++ b/database/migrations/2018_02_24_112356_add_external_id_column_to_servers_table.php @@ -8,10 +8,8 @@ class AddExternalIdColumnToServersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->string('external_id')->after('id')->nullable()->unique(); @@ -20,10 +18,8 @@ class AddExternalIdColumnToServersTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('external_id'); diff --git a/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php b/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php index 6469867f2..e432e56dd 100644 --- a/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php +++ b/database/migrations/2018_02_25_160152_remove_default_null_value_on_table.php @@ -13,7 +13,7 @@ class RemoveDefaultNullValueOnTable extends Migration * @throws \Exception * @throws \Throwable */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->string('external_id')->default(null)->change(); @@ -28,10 +28,8 @@ class RemoveDefaultNullValueOnTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { // This should not be rolled back. } diff --git a/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php b/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php index 0a9b8afe2..38469af23 100644 --- a/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php +++ b/database/migrations/2018_02_25_160604_define_unique_index_on_users_external_id.php @@ -8,10 +8,8 @@ class DefineUniqueIndexOnUsersExternalId extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('users', function (Blueprint $table) { $table->index(['external_id']); @@ -20,10 +18,8 @@ class DefineUniqueIndexOnUsersExternalId extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropIndex(['external_id']); diff --git a/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php b/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php index 4e85e8aeb..00fbd11c2 100644 --- a/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php +++ b/database/migrations/2018_03_01_192831_add_database_and_port_limit_columns_to_servers_table.php @@ -8,10 +8,8 @@ class AddDatabaseAndPortLimitColumnsToServersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('database_limit')->after('installed')->nullable()->default(0); @@ -21,10 +19,8 @@ class AddDatabaseAndPortLimitColumnsToServersTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn(['database_limit', 'allocation_limit']); diff --git a/database/migrations/2018_03_15_124536_add_description_to_nodes.php b/database/migrations/2018_03_15_124536_add_description_to_nodes.php index 7208a4207..a5c1b7542 100644 --- a/database/migrations/2018_03_15_124536_add_description_to_nodes.php +++ b/database/migrations/2018_03_15_124536_add_description_to_nodes.php @@ -8,10 +8,8 @@ class AddDescriptionToNodes extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->text('description')->after('name'); @@ -20,10 +18,8 @@ class AddDescriptionToNodes extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { $table->dropColumn('description'); diff --git a/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php b/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php index 04fdf000f..e85eca8cd 100644 --- a/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php +++ b/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php @@ -8,10 +8,8 @@ class AddMaintenanceToNodes extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->boolean('maintenance_mode')->after('behind_proxy')->default(false); @@ -20,10 +18,8 @@ class AddMaintenanceToNodes extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { $table->dropColumn('maintenance_mode'); diff --git a/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php b/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php index 199650940..e7a4089fa 100644 --- a/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php +++ b/database/migrations/2018_09_03_143756_allow_egg_variables_to_have_longer_values.php @@ -8,10 +8,8 @@ class AllowEggVariablesToHaveLongerValues extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('egg_variables', function (Blueprint $table) { $table->text('default_value')->change(); @@ -20,10 +18,8 @@ class AllowEggVariablesToHaveLongerValues extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('egg_variables', function (Blueprint $table) { $table->string('default_value')->change(); diff --git a/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php b/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php index cc90e0e06..a1d581819 100644 --- a/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php +++ b/database/migrations/2018_09_03_144005_allow_server_variables_to_have_longer_values.php @@ -8,10 +8,8 @@ class AllowServerVariablesToHaveLongerValues extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('server_variables', function (Blueprint $table) { $table->text('variable_value')->change(); @@ -20,10 +18,8 @@ class AllowServerVariablesToHaveLongerValues extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('server_variables', function (Blueprint $table) { $table->string('variable_value')->change(); diff --git a/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php b/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php index d91ce6372..6d43197de 100644 --- a/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php +++ b/database/migrations/2019_03_02_142328_set_allocation_limit_default_null.php @@ -8,10 +8,8 @@ class SetAllocationLimitDefaultNull extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('allocation_limit')->nullable()->default(null)->change(); @@ -20,10 +18,8 @@ class SetAllocationLimitDefaultNull extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('allocation_limit')->nullable()->default(0)->change(); diff --git a/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php b/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php index 59425aee7..de110a06b 100644 --- a/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php +++ b/database/migrations/2019_03_02_151321_fix_unique_index_to_account_for_host.php @@ -8,10 +8,8 @@ class FixUniqueIndexToAccountForHost extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->dropUnique(['database']); @@ -24,10 +22,8 @@ class FixUniqueIndexToAccountForHost extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { $table->dropForeign(['database_host_id']); diff --git a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php index 27d26674f..b71189fe0 100644 --- a/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php +++ b/database/migrations/2020_03_22_163911_merge_permissions_table_into_subusers.php @@ -61,10 +61,8 @@ class MergePermissionsTableIntoSubusers extends Migration /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('subusers', function (Blueprint $table) { $table->json('permissions')->nullable()->after('server_id'); @@ -72,7 +70,12 @@ class MergePermissionsTableIntoSubusers extends Migration $cursor = DB::table('permissions') ->select(['subuser_id']) - ->selectRaw('GROUP_CONCAT(permission) as permissions') + ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'mysql', function ($query) { + $query->selectRaw('group_concat(permission) as permissions'); + }) + ->when(DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME) === 'pgsql', function ($query) { + $query->selectRaw("string_agg(permission, ',') as permissions"); + }) ->from('permissions') ->groupBy(['subuser_id']) ->cursor(); @@ -98,10 +101,8 @@ class MergePermissionsTableIntoSubusers extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { $flipped = array_flip(array_filter(self::$permissionsMap)); diff --git a/database/migrations/2020_03_22_164814_drop_permissions_table.php b/database/migrations/2020_03_22_164814_drop_permissions_table.php index da9d677a8..030a8a6ba 100644 --- a/database/migrations/2020_03_22_164814_drop_permissions_table.php +++ b/database/migrations/2020_03_22_164814_drop_permissions_table.php @@ -8,20 +8,16 @@ class DropPermissionsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::dropIfExists('permissions'); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::create('permissions', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php b/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php index 9b0202cab..d4c08c5e5 100644 --- a/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php +++ b/database/migrations/2020_04_03_203624_add_threads_column_to_servers_table.php @@ -8,10 +8,8 @@ class AddThreadsColumnToServersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->string('threads')->nullable()->after('cpu'); @@ -20,10 +18,8 @@ class AddThreadsColumnToServersTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('threads'); diff --git a/database/migrations/2020_04_03_230614_create_backups_table.php b/database/migrations/2020_04_03_230614_create_backups_table.php index daa35dd3b..a8c28d96d 100644 --- a/database/migrations/2020_04_03_230614_create_backups_table.php +++ b/database/migrations/2020_04_03_230614_create_backups_table.php @@ -9,10 +9,8 @@ class CreateBackupsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { $db = config('database.default'); // There exists a backups plugin for the 0.7 version of the Panel. However, it didn't properly @@ -49,10 +47,8 @@ class CreateBackupsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('backups'); } diff --git a/database/migrations/2020_04_04_131016_add_table_server_transfers.php b/database/migrations/2020_04_04_131016_add_table_server_transfers.php index 096b5384f..c9f3e849a 100644 --- a/database/migrations/2020_04_04_131016_add_table_server_transfers.php +++ b/database/migrations/2020_04_04_131016_add_table_server_transfers.php @@ -8,10 +8,8 @@ class AddTableServerTransfers extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { // Nuclear approach to whatever plugins are out there and not properly namespacing their own tables // leading to constant support requests from people... @@ -20,13 +18,13 @@ class AddTableServerTransfers extends Migration Schema::create('server_transfers', function (Blueprint $table) { $table->increments('id'); $table->integer('server_id')->unsigned(); - $table->tinyInteger('successful')->unsigned()->default(0); + $table->boolean('successful')->unsigned()->default(0); $table->integer('old_node')->unsigned(); $table->integer('new_node')->unsigned(); $table->integer('old_allocation')->unsigned(); $table->integer('new_allocation')->unsigned(); - $table->string('old_additional_allocations')->nullable(); - $table->string('new_additional_allocations')->nullable(); + $table->json('old_additional_allocations')->nullable(); + $table->json('new_additional_allocations')->nullable(); $table->timestamps(); $table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade'); @@ -35,10 +33,8 @@ class AddTableServerTransfers extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('server_transfers'); } diff --git a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php index 6544679fe..a69dafc89 100644 --- a/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php +++ b/database/migrations/2020_04_10_141024_store_node_tokens_as_encrypted_value.php @@ -13,11 +13,9 @@ class StoreNodeTokensAsEncryptedValue extends Migration /** * Run the migrations. * - * @return void - * * @throws \Exception */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->dropUnique(['daemonSecret']); @@ -26,7 +24,8 @@ class StoreNodeTokensAsEncryptedValue extends Migration Schema::table('nodes', function (Blueprint $table) { $table->char('uuid', 36)->after('id'); $table->char('daemon_token_id', 16)->after('upload_size'); - $table->renameColumn('daemonSecret', 'daemon_token'); + + $table->renameColumn('`daemonSecret`', 'daemon_token'); }); Schema::table('nodes', function (Blueprint $table) { @@ -53,10 +52,8 @@ class StoreNodeTokensAsEncryptedValue extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { DB::transaction(function () { /** @var \Illuminate\Contracts\Encryption\Encrypter $encrypter */ diff --git a/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php b/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php index dfd55fb42..8c2c149cf 100644 --- a/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php +++ b/database/migrations/2020_04_17_203438_allow_nullable_descriptions.php @@ -8,10 +8,8 @@ class AllowNullableDescriptions extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->text('description')->nullable()->change(); @@ -32,10 +30,8 @@ class AllowNullableDescriptions extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->text('description')->nullable(false)->change(); diff --git a/database/migrations/2020_04_22_055500_add_max_connections_column.php b/database/migrations/2020_04_22_055500_add_max_connections_column.php index 02253dfd7..57604117c 100644 --- a/database/migrations/2020_04_22_055500_add_max_connections_column.php +++ b/database/migrations/2020_04_22_055500_add_max_connections_column.php @@ -8,10 +8,8 @@ class AddMaxConnectionsColumn extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->integer('max_connections')->nullable()->default(0)->after('password'); @@ -20,10 +18,8 @@ class AddMaxConnectionsColumn extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { $table->dropColumn('max_connections'); diff --git a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php index b0f859c9f..af1b72e64 100644 --- a/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php +++ b/database/migrations/2020_04_26_111208_add_backup_limit_to_servers.php @@ -9,10 +9,8 @@ class AddBackupLimitToServers extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { $db = config('database.default'); // Same as in the backups migration, we need to handle that plugin messing with the data structure @@ -35,10 +33,8 @@ class AddBackupLimitToServers extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('backup_limit'); diff --git a/database/migrations/2020_05_20_234655_add_mounts_table.php b/database/migrations/2020_05_20_234655_add_mounts_table.php index 09846a0a5..db3b409d8 100644 --- a/database/migrations/2020_05_20_234655_add_mounts_table.php +++ b/database/migrations/2020_05_20_234655_add_mounts_table.php @@ -8,10 +8,8 @@ class AddMountsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('mounts', function (Blueprint $table) { $table->increments('id')->unique(); @@ -41,10 +39,8 @@ class AddMountsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('mount_node'); Schema::dropIfExists('egg_mount'); diff --git a/database/migrations/2020_05_21_192756_add_mount_server_table.php b/database/migrations/2020_05_21_192756_add_mount_server_table.php index 682bd578d..7d8e9438b 100644 --- a/database/migrations/2020_05_21_192756_add_mount_server_table.php +++ b/database/migrations/2020_05_21_192756_add_mount_server_table.php @@ -8,10 +8,8 @@ class AddMountServerTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('mount_server', function (Blueprint $table) { $table->integer('server_id'); @@ -23,10 +21,8 @@ class AddMountServerTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('mount_server'); } diff --git a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php b/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php index 9b0743af2..11a6f513c 100644 --- a/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php +++ b/database/migrations/2020_07_02_213612_create_user_recovery_tokens_table.php @@ -8,10 +8,8 @@ class CreateUserRecoveryTokensTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('recovery_tokens', function (Blueprint $table) { $table->id(); @@ -25,10 +23,8 @@ class CreateUserRecoveryTokensTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('recovery_tokens'); } diff --git a/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php b/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php index 711495edf..a93b48053 100644 --- a/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php +++ b/database/migrations/2020_07_09_201845_add_notes_column_for_allocations.php @@ -8,10 +8,8 @@ class AddNotesColumnForAllocations extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('allocations', function (Blueprint $table) { $table->string('notes')->nullable()->after('server_id'); @@ -20,10 +18,8 @@ class AddNotesColumnForAllocations extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('allocations', function (Blueprint $table) { $table->dropColumn('notes'); diff --git a/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php b/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php index 9e6faa42b..4ac99fedd 100644 --- a/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php +++ b/database/migrations/2020_08_20_205533_add_backup_state_column_to_backups.php @@ -8,10 +8,8 @@ class AddBackupStateColumnToBackups extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->boolean('is_successful')->after('uuid')->default(true); @@ -20,10 +18,8 @@ class AddBackupStateColumnToBackups extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->dropColumn('is_successful'); diff --git a/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php b/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php index e8e9c38f3..5c4adca1a 100644 --- a/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php +++ b/database/migrations/2020_08_22_132500_update_bytes_to_unsigned_bigint.php @@ -8,10 +8,8 @@ class UpdateBytesToUnsignedBigint extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->unsignedBigInteger('bytes')->default(0)->change(); @@ -20,10 +18,8 @@ class UpdateBytesToUnsignedBigint extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->integer('bytes')->default(0)->change(); diff --git a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php b/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php index 0de248bfd..763b20457 100644 --- a/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php +++ b/database/migrations/2020_08_23_175331_modify_checksums_column_for_backups.php @@ -9,10 +9,8 @@ class ModifyChecksumsColumnForBackups extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->renameColumn('sha256_hash', 'checksum'); @@ -25,10 +23,8 @@ class ModifyChecksumsColumnForBackups extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->renameColumn('checksum', 'sha256_hash'); diff --git a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php index 638435a81..53cba54f5 100644 --- a/database/migrations/2020_09_13_110007_drop_packs_from_servers.php +++ b/database/migrations/2020_09_13_110007_drop_packs_from_servers.php @@ -8,10 +8,8 @@ class DropPacksFromServers extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->dropForeign(['pack_id']); @@ -21,10 +19,8 @@ class DropPacksFromServers extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedInteger('pack_id')->after('egg_id')->nullable(); diff --git a/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php b/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php index 9bcce8d4d..7c051db2c 100644 --- a/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php +++ b/database/migrations/2020_09_13_110021_drop_packs_from_api_key_permissions.php @@ -8,10 +8,8 @@ class DropPacksFromApiKeyPermissions extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('api_keys', function (Blueprint $table) { $table->dropColumn('r_packs'); @@ -20,10 +18,8 @@ class DropPacksFromApiKeyPermissions extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('api_keys', function (Blueprint $table) { $table->unsignedTinyInteger('r_packs')->default(0); diff --git a/database/migrations/2020_09_13_110047_drop_packs_table.php b/database/migrations/2020_09_13_110047_drop_packs_table.php index 4f83c0f2e..58194b8fa 100644 --- a/database/migrations/2020_09_13_110047_drop_packs_table.php +++ b/database/migrations/2020_09_13_110047_drop_packs_table.php @@ -8,20 +8,16 @@ class DropPacksTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::dropIfExists('packs'); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::create('packs', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2020_09_13_113503_drop_daemon_key_table.php b/database/migrations/2020_09_13_113503_drop_daemon_key_table.php index 7b90d41b9..274f9fd97 100644 --- a/database/migrations/2020_09_13_113503_drop_daemon_key_table.php +++ b/database/migrations/2020_09_13_113503_drop_daemon_key_table.php @@ -8,20 +8,16 @@ class DropDaemonKeyTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::dropIfExists('daemon_keys'); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::create('daemon_keys', function (Blueprint $table) { $table->increments('id'); diff --git a/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php b/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php index 7420989a7..6a277e449 100644 --- a/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php +++ b/database/migrations/2020_10_10_165437_change_unique_database_name_to_account_for_server.php @@ -8,10 +8,8 @@ class ChangeUniqueDatabaseNameToAccountForServer extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('databases', function (Blueprint $table) { $table->dropUnique(['database_host_id', 'database']); @@ -24,10 +22,8 @@ class ChangeUniqueDatabaseNameToAccountForServer extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('databases', function (Blueprint $table) { $table->dropUnique(['database_host_id', 'server_id', 'database']); diff --git a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php b/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php index 69593e656..d0b3118e5 100644 --- a/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php +++ b/database/migrations/2020_10_26_194904_remove_nullable_from_schedule_name_field.php @@ -9,10 +9,8 @@ class RemoveNullableFromScheduleNameField extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { DB::update("UPDATE schedules SET name = 'Schedule' WHERE name IS NULL OR name = ''"); @@ -23,10 +21,8 @@ class RemoveNullableFromScheduleNameField extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('schedules', function (Blueprint $table) { $table->string('name')->nullable()->change(); diff --git a/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php b/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php index 1a001ae98..e134fe9a6 100644 --- a/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php +++ b/database/migrations/2020_11_02_201014_add_features_column_to_eggs.php @@ -8,10 +8,8 @@ class AddFeaturesColumnToEggs extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->json('features')->after('description')->nullable(); @@ -20,10 +18,8 @@ class AddFeaturesColumnToEggs extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('features'); diff --git a/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php b/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php index 776d3c6ba..c7d2cff7f 100644 --- a/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php +++ b/database/migrations/2020_12_12_102435_support_multiple_docker_images_and_updates.php @@ -9,19 +9,22 @@ class SupportMultipleDockerImagesAndUpdates extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->json('docker_images')->after('docker_image')->nullable(); $table->text('update_url')->after('docker_images')->nullable(); }); - Schema::table('eggs', function (Blueprint $table) { - DB::statement('UPDATE `eggs` SET `docker_images` = JSON_ARRAY(docker_image)'); - }); + switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::table('eggs')->update(['docker_images' => DB::raw('JSON_ARRAY(docker_image)')]); + break; + case 'pgsql': + DB::table('eggs')->update(['docker_images' => DB::raw('jsonb_build_array(docker_image)')]); + break; + } Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('docker_image'); @@ -30,18 +33,22 @@ class SupportMultipleDockerImagesAndUpdates extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->text('docker_image')->after('docker_images'); }); - Schema::table('eggs', function (Blueprint $table) { - DB::statement('UPDATE `eggs` SET `docker_image` = JSON_UNQUOTE(JSON_EXTRACT(docker_images, "$[0]"))'); - }); + switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::table('eggs')->update(['docker_images' => DB::raw('JSON_UNQUOTE(JSON_EXTRACT(docker_images, "$[0]")')]); + break; + case 'pgsql': + DB::table('eggs')->update(['docker_images' => DB::raw('JSON_UNQUOTE(JSON_EXTRACT(docker_images, "$[0]")')]); + DB::table('eggs')->update(['docker_images' => DB::raw('docker_images->>0')]); + break; + } Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('docker_images'); diff --git a/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php b/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php index 0a2885284..4c28b6c2b 100644 --- a/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php +++ b/database/migrations/2020_12_14_013707_make_successful_nullable_in_server_transfers.php @@ -8,10 +8,8 @@ class MakeSuccessfulNullableInServerTransfers extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('server_transfers', function (Blueprint $table) { $table->boolean('successful')->nullable()->default(null)->change(); @@ -20,10 +18,8 @@ class MakeSuccessfulNullableInServerTransfers extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('server_transfers', function (Blueprint $table) { $table->boolean('successful')->default(0)->change(); diff --git a/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php b/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php index 1162d8a4f..bc5d3356d 100644 --- a/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php +++ b/database/migrations/2020_12_17_014330_add_archived_field_to_server_transfers_table.php @@ -9,27 +9,21 @@ class AddArchivedFieldToServerTransfersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('server_transfers', function (Blueprint $table) { $table->boolean('archived')->default(0)->after('new_additional_allocations'); }); // Update archived to all be true on existing transfers. - Schema::table('server_transfers', function (Blueprint $table) { - DB::statement('UPDATE `server_transfers` SET `archived` = 1 WHERE `successful` = 1'); - }); + DB::table('server_transfers')->where('successful', true)->update(['archived' => 1]); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('server_transfers', function (Blueprint $table) { $table->dropColumn('archived'); diff --git a/database/migrations/2020_12_24_092449_make_allocation_fields_json.php b/database/migrations/2020_12_24_092449_make_allocation_fields_json.php deleted file mode 100644 index bceec9de7..000000000 --- a/database/migrations/2020_12_24_092449_make_allocation_fields_json.php +++ /dev/null @@ -1,34 +0,0 @@ -json('old_additional_allocations')->nullable()->change(); - $table->json('new_additional_allocations')->nullable()->change(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('server_transfers', function (Blueprint $table) { - $table->string('old_additional_allocations')->nullable()->change(); - $table->string('new_additional_allocations')->nullable()->change(); - }); - } -} diff --git a/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php b/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php index 2e1c50556..771e06ab1 100644 --- a/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php +++ b/database/migrations/2020_12_26_184914_add_upload_id_column_to_backups_table.php @@ -8,10 +8,8 @@ class AddUploadIdColumnToBackupsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->text('upload_id')->nullable()->after('uuid'); @@ -20,10 +18,8 @@ class AddUploadIdColumnToBackupsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->dropColumn('upload_id'); diff --git a/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php b/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php index 8d617fc19..4a956625e 100644 --- a/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php +++ b/database/migrations/2021_01_10_153937_add_file_denylist_to_egg_configs.php @@ -8,10 +8,8 @@ class AddFileDenylistToEggConfigs extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->text('file_denylist')->after('docker_images'); @@ -20,10 +18,8 @@ class AddFileDenylistToEggConfigs extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('file_denylist'); diff --git a/database/migrations/2021_01_13_013420_add_cron_month.php b/database/migrations/2021_01_13_013420_add_cron_month.php index 85e534248..da0bf8841 100644 --- a/database/migrations/2021_01_13_013420_add_cron_month.php +++ b/database/migrations/2021_01_13_013420_add_cron_month.php @@ -8,10 +8,8 @@ class AddCronMonth extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('schedules', function (Blueprint $table) { $table->string('cron_month')->after('cron_day_of_week'); @@ -20,10 +18,8 @@ class AddCronMonth extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('schedules', function (Blueprint $table) { $table->dropColumn('cron_month'); diff --git a/database/migrations/2021_01_17_102401_create_audit_logs_table.php b/database/migrations/2021_01_17_102401_create_audit_logs_table.php index f67e7d647..d0fddf801 100644 --- a/database/migrations/2021_01_17_102401_create_audit_logs_table.php +++ b/database/migrations/2021_01_17_102401_create_audit_logs_table.php @@ -8,10 +8,8 @@ class CreateAuditLogsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('audit_logs', function (Blueprint $table) { $table->id(); @@ -32,10 +30,8 @@ class CreateAuditLogsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('audit_logs'); } diff --git a/database/migrations/2021_01_17_152623_add_generic_server_status_column.php b/database/migrations/2021_01_17_152623_add_generic_server_status_column.php index 12e6abb95..f8c9dec2c 100644 --- a/database/migrations/2021_01_17_152623_add_generic_server_status_column.php +++ b/database/migrations/2021_01_17_152623_add_generic_server_status_column.php @@ -9,20 +9,16 @@ class AddGenericServerStatusColumn extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->string('status')->nullable()->after('description'); }); - DB::transaction(function () { - DB::update('UPDATE servers SET `status` = \'suspended\' WHERE `suspended` = 1'); - DB::update('UPDATE servers SET `status` = \'installing\' WHERE `installed` = 0'); - DB::update('UPDATE servers SET `status` = \'install_failed\' WHERE `installed` = 2'); - }); + DB::table('servers')->where('suspended', 1)->update(['status' => 'suspended']); + DB::table('servers')->where('installed', 1)->update(['status' => 'installing']); + DB::table('servers')->where('installed', 1)->update(['status' => 'install_failed']); Schema::table('servers', function (Blueprint $table) { $table->dropColumn('suspended'); @@ -32,21 +28,17 @@ class AddGenericServerStatusColumn extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->unsignedTinyInteger('suspended')->default(0); $table->unsignedTinyInteger('installed')->default(0); }); - DB::transaction(function () { - DB::update('UPDATE servers SET `suspended` = 1 WHERE `status` = \'suspended\''); - DB::update('UPDATE servers SET `installed` = 1 WHERE `status` IS NULL'); - DB::update('UPDATE servers SET `installed` = 2 WHERE `status` = \'install_failed\''); - }); + DB::table('servers')->where('status', 'suspended')->update(['suspended' => 1]); + DB::table('servers')->whereNull('status')->update(['installed' => 1]); + DB::table('servers')->where('status', 'install_failed')->update(['installed' => 2]); Schema::table('servers', function (Blueprint $table) { $table->dropColumn('status'); diff --git a/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php b/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php index af4961135..7c2c5fa06 100644 --- a/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php +++ b/database/migrations/2021_01_26_210502_update_file_denylist_to_json.php @@ -8,10 +8,8 @@ class UpdateFileDenylistToJson extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('file_denylist'); @@ -24,10 +22,8 @@ class UpdateFileDenylistToJson extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('file_denylist'); diff --git a/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php b/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php index 888125468..1fd63559c 100644 --- a/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php +++ b/database/migrations/2021_02_23_205021_add_index_for_server_and_action.php @@ -8,10 +8,8 @@ class AddIndexForServerAndAction extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('audit_logs', function (Blueprint $table) { // Doing the index in this order lets me use the action alone without the server @@ -27,10 +25,8 @@ class AddIndexForServerAndAction extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('audit_logs', function (Blueprint $table) { $table->dropIndex(['action', 'server_id']); diff --git a/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php b/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php index 8eea84819..b9196a0ae 100644 --- a/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php +++ b/database/migrations/2021_02_23_212657_make_sftp_port_unsigned_int.php @@ -8,10 +8,8 @@ class MakeSftpPortUnsignedInt extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('nodes', function (Blueprint $table) { $table->unsignedSmallInteger('daemonSFTP')->default(2022)->change(); @@ -20,10 +18,8 @@ class MakeSftpPortUnsignedInt extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('nodes', function (Blueprint $table) { $table->smallInteger('daemonSFTP')->default(2022)->change(); diff --git a/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php b/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php index 57e129952..61abdbd6c 100644 --- a/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php +++ b/database/migrations/2021_03_21_104718_force_cron_month_field_to_have_value_if_missing.php @@ -1,30 +1,22 @@ where('cron_month', '')->update(['cron_month' => '*']); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { // No down function. } diff --git a/database/migrations/2021_05_01_092457_add_continue_on_failure_option_to_tasks.php b/database/migrations/2021_05_01_092457_add_continue_on_failure_option_to_tasks.php index 703f1524f..079045496 100644 --- a/database/migrations/2021_05_01_092457_add_continue_on_failure_option_to_tasks.php +++ b/database/migrations/2021_05_01_092457_add_continue_on_failure_option_to_tasks.php @@ -8,10 +8,8 @@ class AddContinueOnFailureOptionToTasks extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('tasks', function (Blueprint $table) { $table->unsignedTinyInteger('continue_on_failure')->after('is_queued')->default(0); @@ -20,10 +18,8 @@ class AddContinueOnFailureOptionToTasks extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('tasks', function (Blueprint $table) { $table->dropColumn('continue_on_failure'); diff --git a/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php b/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php index 91bb43be9..a0143fdd6 100644 --- a/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php +++ b/database/migrations/2021_05_01_092523_add_only_run_when_server_online_option_to_schedules.php @@ -8,10 +8,8 @@ class AddOnlyRunWhenServerOnlineOptionToSchedules extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('schedules', function (Blueprint $table) { $table->unsignedTinyInteger('only_when_online')->after('is_processing')->default(0); @@ -20,10 +18,8 @@ class AddOnlyRunWhenServerOnlineOptionToSchedules extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('schedules', function (Blueprint $table) { $table->dropColumn('only_when_online'); diff --git a/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php b/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php index bafa4dd76..3296e3e8f 100644 --- a/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php +++ b/database/migrations/2021_05_03_201016_add_support_for_locking_a_backup.php @@ -8,10 +8,8 @@ class AddSupportForLockingABackup extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->unsignedTinyInteger('is_locked')->after('is_successful')->default(0); @@ -20,10 +18,8 @@ class AddSupportForLockingABackup extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->dropColumn('is_locked'); diff --git a/database/migrations/2021_07_12_013420_remove_userinteraction.php b/database/migrations/2021_07_12_013420_remove_userinteraction.php index 05321d4b3..33b4d5d3b 100644 --- a/database/migrations/2021_07_12_013420_remove_userinteraction.php +++ b/database/migrations/2021_07_12_013420_remove_userinteraction.php @@ -7,22 +7,41 @@ class RemoveUserInteraction extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { // Remove User Interaction from startup config - DB::table('eggs')->update([ - 'config_startup' => DB::raw('JSON_REMOVE(config_startup, \'$.userInteraction\')'), - ]); + switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::table('eggs')->update([ + 'config_startup' => DB::raw('JSON_REMOVE(config_startup, \'$.userInteraction\')'), + ]); + break; + case 'pgsql': + DB::table('eggs')->update([ + 'config_startup' => DB::raw('config_startup::jsonb - \'userInteraction\''), + ]); + break; + } } - public function down() + /** + * Reverse the migrations. + */ + public function down(): void { // Add blank User Interaction array back to startup config - DB::table('eggs')->update([ - 'config_startup' => DB::raw('JSON_SET(config_startup, \'$.userInteraction\', JSON_ARRAY())'), - ]); + switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::table('eggs')->update([ + 'config_startup' => DB::raw('JSON_SET(config_startup, \'$.userInteraction\', JSON_ARRAY())'), + ]); + break; + case 'pgsql': + DB::table('eggs')->update([ + 'config_startup' => DB::raw('jsonb_set(config_startup::jsonb, \'$.userInteraction\', jsonb_build_array())'), + ]); + break; + } } } diff --git a/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php b/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php index d5b8a13c6..a33bb4d31 100644 --- a/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php +++ b/database/migrations/2021_07_17_211512_create_user_ssh_keys_table.php @@ -9,7 +9,7 @@ class CreateUserSshKeysTable extends Migration /** * Run the migrations. */ - public function up() + public function up(): void { Schema::create('user_ssh_keys', function (Blueprint $table) { $table->increments('id'); @@ -27,7 +27,7 @@ class CreateUserSshKeysTable extends Migration /** * Reverse the migrations. */ - public function down() + public function down(): void { Schema::dropIfExists('user_ssh_keys'); } diff --git a/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php b/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php index d47b0e5d2..b9284eb0c 100644 --- a/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php +++ b/database/migrations/2021_08_03_210600_change_successful_field_to_default_to_false_on_backups_table.php @@ -9,10 +9,8 @@ class ChangeSuccessfulFieldToDefaultToFalseOnBackupsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('backups', function (Blueprint $table) { $table->boolean('is_successful')->after('uuid')->default(false)->change(); @@ -26,10 +24,8 @@ class ChangeSuccessfulFieldToDefaultToFalseOnBackupsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('backups', function (Blueprint $table) { $table->boolean('is_successful')->after('uuid')->default(true)->change(); diff --git a/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php b/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php index fad8dc193..5210f60d2 100644 --- a/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php +++ b/database/migrations/2021_08_21_175111_add_foreign_keys_to_mount_node_table.php @@ -9,10 +9,8 @@ class AddForeignKeysToMountNodeTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { // Fix the columns having a different type than their relations. Schema::table('mount_node', function (Blueprint $table) { @@ -46,10 +44,8 @@ class AddForeignKeysToMountNodeTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('mount_node', function (Blueprint $table) { $table->dropForeign(['node_id']); diff --git a/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php b/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php index 9c5a403b2..f564ec491 100644 --- a/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php +++ b/database/migrations/2021_08_21_175118_add_foreign_keys_to_mount_server_table.php @@ -8,10 +8,8 @@ class AddForeignKeysToMountServerTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { // Fix the columns having a different type than their relations. Schema::table('mount_server', function (Blueprint $table) { @@ -45,10 +43,8 @@ class AddForeignKeysToMountServerTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('mount_server', function (Blueprint $table) { $table->dropForeign(['server_id']); diff --git a/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php b/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php index 7bf99506b..11285a5c5 100644 --- a/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php +++ b/database/migrations/2021_08_21_180921_add_foreign_keys_to_egg_mount_table.php @@ -8,10 +8,8 @@ class AddForeignKeysToEggMountTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { // Fix the columns having a different type than their relations. Schema::table('egg_mount', function (Blueprint $table) { @@ -45,10 +43,8 @@ class AddForeignKeysToEggMountTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('egg_mount', function (Blueprint $table) { $table->dropForeign(['egg_id']); diff --git a/database/migrations/2022_01_25_030847_drop_google_analytics.php b/database/migrations/2022_01_25_030847_drop_google_analytics.php index 5daf0bc39..0d65e5d4d 100644 --- a/database/migrations/2022_01_25_030847_drop_google_analytics.php +++ b/database/migrations/2022_01_25_030847_drop_google_analytics.php @@ -7,25 +7,19 @@ class DropGoogleAnalytics extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { DB::table('settings')->where('key', 'settings::app:analytics')->delete(); } /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { - DB::table('settings')->insert( - [ + DB::table('settings')->insert([ 'key' => 'settings::app:analytics', - ] - ); + ]); } } diff --git a/database/migrations/2022_05_07_165334_migrate_egg_images_array_to_new_format.php b/database/migrations/2022_05_07_165334_migrate_egg_images_array_to_new_format.php index 78dfe6e37..057ce9d74 100644 --- a/database/migrations/2022_05_07_165334_migrate_egg_images_array_to_new_format.php +++ b/database/migrations/2022_05_07_165334_migrate_egg_images_array_to_new_format.php @@ -10,7 +10,7 @@ class MigrateEggImagesArrayToNewFormat extends Migration * images array to both exist, and have key => value pairings to support naming the * images provided. */ - public function up() + public function up(): void { DB::table('eggs')->select(['id', 'docker_images'])->cursor()->each(function ($egg) { $images = is_null($egg->docker_images) ? [] : json_decode($egg->docker_images, true, 512, JSON_THROW_ON_ERROR); @@ -26,10 +26,8 @@ class MigrateEggImagesArrayToNewFormat extends Migration /** * Reverse the migrations. This just keeps the values from the docker images array. - * - * @return void */ - public function down() + public function down(): void { DB::table('eggs')->select(['id', 'docker_images'])->cursor()->each(function ($egg) { DB::table('eggs')->where('id', $egg->id)->update([ diff --git a/database/migrations/2022_05_28_135717_create_activity_logs_table.php b/database/migrations/2022_05_28_135717_create_activity_logs_table.php index 448439dc8..4c4f05f1f 100644 --- a/database/migrations/2022_05_28_135717_create_activity_logs_table.php +++ b/database/migrations/2022_05_28_135717_create_activity_logs_table.php @@ -8,10 +8,8 @@ class CreateActivityLogsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('activity_logs', function (Blueprint $table) { $table->id(); @@ -27,10 +25,8 @@ class CreateActivityLogsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('activity_logs'); } diff --git a/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php b/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php index 6dc45d7f8..c9997ac41 100644 --- a/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php +++ b/database/migrations/2022_05_29_140349_create_activity_log_actors_table.php @@ -8,10 +8,8 @@ class CreateActivityLogActorsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::create('activity_log_subjects', function (Blueprint $table) { $table->id(); @@ -22,10 +20,8 @@ class CreateActivityLogActorsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::dropIfExists('activity_log_subjects'); } diff --git a/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php b/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php index 6e35df9a2..f13878637 100644 --- a/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php +++ b/database/migrations/2022_06_18_112822_track_api_key_usage_for_activity_events.php @@ -7,10 +7,8 @@ use Illuminate\Database\Migrations\Migration; return new class () extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('activity_logs', function (Blueprint $table) { $table->unsignedInteger('api_key_id')->nullable()->after('actor_id'); @@ -19,10 +17,8 @@ return new class () extends Migration { /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('activity_logs', function (Blueprint $table) { $table->dropColumn('api_key_id'); diff --git a/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php b/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php index eb3a56bf2..c5b30a49a 100644 --- a/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php +++ b/database/migrations/2022_08_16_214400_add_force_outgoing_ip_column_to_eggs_table.php @@ -8,10 +8,8 @@ class AddForceOutgoingIpColumnToEggsTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('eggs', function (Blueprint $table) { $table->boolean('force_outgoing_ip')->default(false); @@ -20,10 +18,8 @@ class AddForceOutgoingIpColumnToEggsTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('eggs', function (Blueprint $table) { $table->dropColumn('force_outgoing_ip'); diff --git a/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php b/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php index 50a5e23f8..541117a3a 100644 --- a/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php +++ b/database/migrations/2022_08_16_230204_add_installed_at_column_to_servers_table.php @@ -8,10 +8,8 @@ class AddInstalledAtColumnToServersTable extends Migration { /** * Run the migrations. - * - * @return void */ - public function up() + public function up(): void { Schema::table('servers', function (Blueprint $table) { $table->timestamp('installed_at')->nullable(); @@ -20,10 +18,8 @@ class AddInstalledAtColumnToServersTable extends Migration /** * Reverse the migrations. - * - * @return void */ - public function down() + public function down(): void { Schema::table('servers', function (Blueprint $table) { $table->dropColumn('installed_at'); diff --git a/database/migrations/2022_11_01_163744_make_ignored_files_column_nullable_on_backups_table.php b/database/migrations/2022_11_01_163744_make_ignored_files_column_nullable_on_backups_table.php new file mode 100644 index 000000000..ed36c6468 --- /dev/null +++ b/database/migrations/2022_11_01_163744_make_ignored_files_column_nullable_on_backups_table.php @@ -0,0 +1,27 @@ +text('ignored_files')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('backups', function (Blueprint $table) { + $table->text('ignored_files')->change(); + }); + } +}; diff --git a/database/migrations/2022_11_01_165830_fix_language_column_type_on_users_table.php b/database/migrations/2022_11_01_165830_fix_language_column_type_on_users_table.php new file mode 100644 index 000000000..0268810fd --- /dev/null +++ b/database/migrations/2022_11_01_165830_fix_language_column_type_on_users_table.php @@ -0,0 +1,36 @@ +getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::statement('ALTER TABLE users MODIFY COLUMN language VARCHAR(5)'); + break; + case 'pgsql': + DB::statement('ALTER TABLE users ALTER COLUMN language TYPE varchar(5)'); + break; + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + switch (DB::getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME)) { + case 'mysql': + DB::statement('ALTER TABLE users MODIFY COLUMN language CHAR(5)'); + break; + case 'pgsql': + DB::statement('ALTER TABLE users ALTER COLUMN language TYPE CHAR(5)'); + break; + } + } +}; diff --git a/phpunit.xml b/phpunit.xml index efc42d687..5319118fd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -24,8 +24,8 @@ + - diff --git a/tests/Integration/Api/Application/Location/LocationControllerTest.php b/tests/Integration/Api/Application/Location/LocationControllerTest.php index ed75413ac..7a02092b1 100644 --- a/tests/Integration/Api/Application/Location/LocationControllerTest.php +++ b/tests/Integration/Api/Application/Location/LocationControllerTest.php @@ -249,7 +249,7 @@ class LocationControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingLocation() { - $response = $this->getJson('/api/application/locations/nil'); + $response = $this->getJson('/api/application/locations/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Application/Nests/EggControllerTest.php b/tests/Integration/Api/Application/Nests/EggControllerTest.php index 07a527e0f..e41b20eb4 100644 --- a/tests/Integration/Api/Application/Nests/EggControllerTest.php +++ b/tests/Integration/Api/Application/Nests/EggControllerTest.php @@ -104,7 +104,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = Egg::query()->findOrFail(1); - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil'); + $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Application/Nests/NestControllerTest.php b/tests/Integration/Api/Application/Nests/NestControllerTest.php index 799fc18ac..5cbed783c 100644 --- a/tests/Integration/Api/Application/Nests/NestControllerTest.php +++ b/tests/Integration/Api/Application/Nests/NestControllerTest.php @@ -108,7 +108,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingNest() { - $response = $this->getJson('/api/application/nests/nil'); + $response = $this->getJson('/api/application/nests/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index fc37b7232..1c02df7fc 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -51,7 +51,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingUser() { - $response = $this->getJson('/api/application/users/external/nil'); + $response = $this->getJson('/api/application/users/external/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 713f6264a..0aebe3d9b 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -184,7 +184,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingUser() { - $response = $this->getJson('/api/application/users/nil'); + $response = $this->getJson('/api/application/users/0'); $this->assertNotFoundJson($response); } diff --git a/tests/Integration/Api/Client/ClientControllerTest.php b/tests/Integration/Api/Client/ClientControllerTest.php index 033b893c3..ed0cada00 100644 --- a/tests/Integration/Api/Client/ClientControllerTest.php +++ b/tests/Integration/Api/Client/ClientControllerTest.php @@ -18,10 +18,10 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testOnlyLoggedInUsersServersAreReturned() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(3)->create(); - /** @var \Pterodactyl\Models\Server[] $servers */ + /** @var Server[] $servers */ $servers = [ $this->createServerModel(['user_id' => $users[0]->id]), $this->createServerModel(['user_id' => $users[1]->id]), @@ -45,11 +45,11 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testServersAreFilteredUsingNameAndUuidInformation() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(2)->create(); $users[0]->update(['root_admin' => true]); - /** @var \Pterodactyl\Models\Server[] $servers */ + /** @var Server[] $servers */ $servers = [ $this->createServerModel(['user_id' => $users[0]->id, 'name' => 'Julia']), $this->createServerModel(['user_id' => $users[1]->id, 'uuidShort' => '12121212', 'name' => 'Janice']), @@ -101,8 +101,8 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testServersAreFilteredUsingAllocationInformation() { - /** @var \Pterodactyl\Models\User $user */ - /** @var \Pterodactyl\Models\Server $server */ + /** @var User $user */ + /** @var Server $server */ [$user, $server] = $this->generateTestAccount(); $server2 = $this->createServerModel(['user_id' => $user->id, 'node_id' => $server->node_id]); @@ -143,7 +143,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testServersUserIsASubuserOfAreReturned() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(3)->create(); $servers = [ $this->createServerModel(['user_id' => $users[0]->id]), @@ -174,7 +174,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testFilterOnlyOwnerServers() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(3)->create(); $servers = [ $this->createServerModel(['user_id' => $users[0]->id]), @@ -203,7 +203,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testPermissionsAreReturned() { - /** @var \Pterodactyl\Models\User $user */ + /** @var User $user */ $user = User::factory()->create(); $this->actingAs($user) @@ -223,7 +223,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testOnlyAdminLevelServersAreReturned() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(4)->create(); $users[0]->update(['root_admin' => true]); @@ -258,7 +258,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testAllServersAreReturnedToAdmin() { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(4)->create(); $users[0]->update(['root_admin' => true]); @@ -290,7 +290,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testNoServersAreReturnedIfAdminFilterIsPassedByRegularUser(string $type) { - /** @var \Pterodactyl\Models\User[] $users */ + /** @var User[] $users */ $users = User::factory()->times(3)->create(); $this->createServerModel(['user_id' => $users[0]->id]); @@ -309,7 +309,7 @@ class ClientControllerTest extends ClientApiIntegrationTestCase */ public function testOnlyPrimaryAllocationIsReturnedToSubuser() { - /** @var \Pterodactyl\Models\Server $server */ + /** @var Server $server */ [$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]); $server->allocation->notes = 'Test notes'; $server->allocation->save(); diff --git a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php index a8a5b88e0..3024ecf86 100644 --- a/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php +++ b/tests/Integration/Api/Client/Server/Startup/GetStartupAndVariablesTest.php @@ -42,7 +42,7 @@ class GetStartupAndVariablesTest extends ClientApiIntegrationTestCase $response->assertJsonPath('object', 'list'); $response->assertJsonCount(1, 'data'); $response->assertJsonPath('data.0.object', EggVariable::RESOURCE_NAME); - $this->assertJsonTransformedWith($response->json('data.0.attributes'), $egg->variables[1]); + $this->assertJsonTransformedWith($response->json('data.0.attributes'), $egg->variables()->orderBy('id', 'desc')->first()); } /** diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index 103c97b9b..6672960d3 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -16,7 +16,7 @@ abstract class IntegrationTestCase extends TestCase use CreatesTestModels; use AssertsActivityLogged; - protected array $connectionsToTransact = ['mysql']; +// protected array $connectionsToTransact = ['pgsql']; protected $defaultHeaders = [ 'Accept' => 'application/json', diff --git a/tests/Integration/Services/Servers/ServerCreationServiceTest.php b/tests/Integration/Services/Servers/ServerCreationServiceTest.php index 92a873a18..aef7e8c1e 100644 --- a/tests/Integration/Services/Servers/ServerCreationServiceTest.php +++ b/tests/Integration/Services/Servers/ServerCreationServiceTest.php @@ -127,9 +127,10 @@ class ServerCreationServiceTest extends IntegrationTestCase $this->assertNotNull($response->uuid); $this->assertSame($response->uuidShort, substr($response->uuid, 0, 8)); $this->assertSame($egg->id, $response->egg_id); - $this->assertCount(2, $response->variables); - $this->assertSame('123', $response->variables[0]->server_value); - $this->assertSame('server2.jar', $response->variables[1]->server_value); + $variables = $response->variables->sortBy('server_value')->values(); + $this->assertCount(2, $variables); + $this->assertSame('123', $variables->get(0)->server_value); + $this->assertSame('server2.jar', $variables->get(1)->server_value); foreach ($data as $key => $value) { if (in_array($key, ['allocation_additional', 'environment', 'start_on_completion'])) { diff --git a/tests/Integration/Services/Servers/StartupModificationServiceTest.php b/tests/Integration/Services/Servers/StartupModificationServiceTest.php index 47f4595f0..9106b4740 100644 --- a/tests/Integration/Services/Servers/StartupModificationServiceTest.php +++ b/tests/Integration/Services/Servers/StartupModificationServiceTest.php @@ -109,7 +109,7 @@ class StartupModificationServiceTest extends IntegrationTestCase $clone = $this->cloneEggAndVariables($server->egg); // This makes the BUNGEE_VERSION variable not user editable. - $clone->variables()->first()->update([ + $clone->variables()->orderBy('id')->first()->update([ 'user_editable' => false, ]); @@ -118,7 +118,7 @@ class StartupModificationServiceTest extends IntegrationTestCase ServerVariable::query()->updateOrCreate([ 'server_id' => $server->id, - 'variable_id' => $server->variables[0]->id, + 'variable_id' => $server->variables()->orderBy('id')->first()->id, ], ['variable_value' => 'EXIST']); $response = $this->getService()->handle($server, [ @@ -128,9 +128,10 @@ class StartupModificationServiceTest extends IntegrationTestCase ], ]); - $this->assertCount(2, $response->variables); - $this->assertSame('EXIST', $response->variables[0]->server_value); - $this->assertSame('test.jar', $response->variables[1]->server_value); + $variables = $response->variables->sortBy('server_value')->values(); + $this->assertCount(2, $variables); + $this->assertSame('EXIST', $variables->get(0)->server_value); + $this->assertSame('test.jar', $variables->get(1)->server_value); $response = $this->getService() ->setUserLevel(User::USER_LEVEL_ADMIN) @@ -141,9 +142,11 @@ class StartupModificationServiceTest extends IntegrationTestCase ], ]); - $this->assertCount(2, $response->variables); - $this->assertSame('1234', $response->variables[0]->server_value); - $this->assertSame('test.jar', $response->variables[1]->server_value); + $variables = $response->variables->sortBy('server_value')->values(); + + $this->assertCount(2, $variables); + $this->assertSame('1234', $variables->get(0)->server_value); + $this->assertSame('test.jar', $variables->get(1)->server_value); } /** diff --git a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php index 7f0e157fa..36cfb05d6 100644 --- a/tests/Integration/Services/Servers/VariableValidatorServiceTest.php +++ b/tests/Integration/Services/Servers/VariableValidatorServiceTest.php @@ -108,11 +108,12 @@ class VariableValidatorServiceTest extends IntegrationTestCase ]); $this->assertInstanceOf(Collection::class, $response); - $this->assertCount(2, $response); - $this->assertSame('BUNGEE_VERSION', $response->get(0)->key); - $this->assertSame('123', $response->get(0)->value); - $this->assertSame('SERVER_JARFILE', $response->get(1)->key); - $this->assertSame('server.jar', $response->get(1)->value); + $variables = $response->sortBy('key')->values(); + $this->assertCount(2, $variables); + $this->assertSame('BUNGEE_VERSION', $variables->get(0)->key); + $this->assertSame('123', $variables->get(0)->value); + $this->assertSame('SERVER_JARFILE', $variables->get(1)->key); + $this->assertSame('server.jar', $variables->get(1)->value); } public function testNullableEnvironmentVariablesCanBeUsedCorrectly() diff --git a/tests/Traits/MocksPdoConnection.php b/tests/Traits/MocksPdoConnection.php deleted file mode 100644 index a93896463..000000000 --- a/tests/Traits/MocksPdoConnection.php +++ /dev/null @@ -1,48 +0,0 @@ - $connection]); - $resolver->setDefaultConnection('mocked'); - - Model::setConnectionResolver($resolver); - - return $mock; - } - - /** - * Resets the mock state. - */ - protected function tearDownPdoMock(): void - { - if (!self::$initialResolver) { - return; - } - - Model::setConnectionResolver(self::$initialResolver); - - self::$initialResolver = null; - } -}