From 3fb76004bacaa8275d8c37e84e038f4f767415a0 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 26 May 2023 21:53:44 +0200 Subject: [PATCH] Edit DB Anpassungen --- .env.example | 17 ++- app/Models/Mod.php | 11 -- app/Models/Title.php | 11 -- config/database.php | 15 +++ .../2014_10_12_000000_create_users_table.php | 28 ++-- ...000_create_password_reset_tokens_table.php | 16 ++- ..._08_19_000000_create_failed_jobs_table.php | 24 ++-- ...01_create_personal_access_tokens_table.php | 26 ++-- .../2023_03_18_204557_create_games_table.php | 126 +++++++++--------- .../2023_05_26_205735_create_mods_table.php | 14 +- ...023_05_26_205807_create_modpacks_table.php | 14 +- 11 files changed, 165 insertions(+), 137 deletions(-) delete mode 100644 app/Models/Mod.php delete mode 100644 app/Models/Title.php diff --git a/.env.example b/.env.example index 478972c..b0e991c 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_NAME=Laravel +APP_NAME=Rauru APP_ENV=local APP_KEY= APP_DEBUG=true @@ -8,12 +8,15 @@ LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=laravel -DB_USERNAME=root -DB_PASSWORD= +DB_CONNECTION=pgsql_rauru +DB_HOST=db +DB_PORT=5432 +DB_DATABASE=rauru_db +DB_USERNAME=rauru_user +DB_PASSWORD=secret + +IGDB_CLIENT_ID="y4ezkipsb48y8sdj5aa00kwur2cr1w" +IGDB_ACCESS_TOKEN="oonmo0krok6dysrts70ftx3i8ki7zr" BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/app/Models/Mod.php b/app/Models/Mod.php deleted file mode 100644 index 4fbc856..0000000 --- a/app/Models/Mod.php +++ /dev/null @@ -1,11 +0,0 @@ - [ + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + 'search_path' => 'public', + 'sslmode' => 'prefer', + ], + 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 444fafb..f14601e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -11,15 +11,21 @@ return new class extends Migration */ public function up(): void { - Schema::create('users', function (Blueprint $table) { - $table->id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('users')) { + Schema::connection('pgsql_rauru')->create('users', function (Blueprint $table) { + $table->id(); + $table->string('username'); + $table->string('firstname'); + $table->string('lastname'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + } /** @@ -27,6 +33,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('users'); + if (Schema::connection('pgsql_rauru')->hasTable('users')) { + Schema::connection('pgsql_rauru')->dropIfExists('users'); + } } }; diff --git a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php index 81a7229..e386031 100644 --- a/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php +++ b/database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php @@ -11,11 +11,13 @@ return new class extends Migration */ public function up(): void { - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('password_reset_tokens')) { + Schema::create('password_reset_tokens', function (Blueprint $table) { + $table->string('email')->primary(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } } /** @@ -23,6 +25,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('password_reset_tokens'); + if (Schema::connection('pgsql_rauru')->hasTable('password_reset_tokens')) { + Schema::connection('pgsql_rauru')->dropIfExists('password_reset_tokens'); + } } }; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index 249da81..4e442c8 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -11,15 +11,17 @@ return new class extends Migration */ public function up(): void { - Schema::create('failed_jobs', function (Blueprint $table) { - $table->id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('failed_jobs')) { + Schema::connection('pgsql_rauru')->create('failed_jobs', function (Blueprint $table) { + $table->id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } } /** @@ -27,6 +29,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('failed_jobs'); + if (Schema::connection('pgsql_rauru')->hasTable('failed_jobs')) { + Schema::connection('pgsql_rauru')->dropIfExists('failed_jobs'); + } } }; diff --git a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php index e828ad8..87ed105 100644 --- a/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php +++ b/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -11,16 +11,18 @@ return new class extends Migration */ public function up(): void { - Schema::create('personal_access_tokens', function (Blueprint $table) { - $table->id(); - $table->morphs('tokenable'); - $table->string('name'); - $table->string('token', 64)->unique(); - $table->text('abilities')->nullable(); - $table->timestamp('last_used_at')->nullable(); - $table->timestamp('expires_at')->nullable(); - $table->timestamps(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('personal_access_tokens')) { + Schema::connection('pgsql_rauru')->create('personal_access_tokens', function (Blueprint $table) { + $table->id(); + $table->morphs('tokenable'); + $table->string('name'); + $table->string('token', 64)->unique(); + $table->text('abilities')->nullable(); + $table->timestamp('last_used_at')->nullable(); + $table->timestamp('expires_at')->nullable(); + $table->timestamps(); + }); + } } /** @@ -28,6 +30,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('personal_access_tokens'); + if (Schema::connection('pgsql_rauru')->hasTable('personal_access_tokens')) { + Schema::connection('pgsql_rauru')->dropIfExists('personal_access_tokens'); + } } }; diff --git a/database/migrations/2023_03_18_204557_create_games_table.php b/database/migrations/2023_03_18_204557_create_games_table.php index 4b90233..db86750 100644 --- a/database/migrations/2023_03_18_204557_create_games_table.php +++ b/database/migrations/2023_03_18_204557_create_games_table.php @@ -11,67 +11,69 @@ return new class extends Migration */ public function up(): void { - Schema::create('games', function (Blueprint $table) { - $table->increments('id'); - $table->json('age_ratings'); - $table->string('aggregated_rating'); - $table->integer('aggregated_rating_count'); - $table->json('alternative_names'); - $table->json('artworks'); - //$table->json('bundles'); - $table->integer('category');//enum - $table->uuid('checksum'); - $table->string('collection'); - $table->string('cover_id'); - $table->string('cover_image_path'); - $table->json('dlcs'); - //$table->json('expanded_games'); - $table->json('expansions'); - $table->json('external_games');//IDs on other Platforms - $table->date('first_release_date'); - //$table->integer('follows'); - //$table->json('forks'); - $table->string('franchise'); - $table->json('franchises'); - $table->json('game_engines'); - $table->json('game_localizations'); - $table->json('game_modes'); - $table->json('genres'); - //$table->integer('hypes'); - $table->json('involved_companies'); - $table->json('keywords'); - $table->json('language_supports'); - $table->json('multiplayer_modes'); - $table->string('name'); - $table->string('parent_game'); - $table->json('platforms'); - $table->json('player_perspectives'); - $table->json('ports'); - $table->string('rating');//formated double - //$table->integer('rating_count'); - $table->json('release_dates'); - $table->json('remakes'); - $table->json('remasters'); - $table->json('screenshots'); - $table->json('similar_games'); - $table->string('slug'); - $table->json('standalone_expansions'); - $table->integer('status');//enum - $table->text('storyline'); - $table->text('summary'); - $table->json('tags'); - $table->json('themes'); - $table->string('total_rating');//formated double - //$table->integer('total_rating_count'); - //$table->date('updated_at'); - $table->string('url');//IGDB Url - $table->string('version_parent'); - $table->string('version_title'); - $table->json('videos'); - $table->json('websites'); + if (!Schema::connection('pgsql_rauru')->hasTable('games')) { + Schema::connection('pgsql_rauru')->create('games', function (Blueprint $table) { + $table->increments('id'); + $table->json('age_ratings'); + $table->string('aggregated_rating'); + $table->integer('aggregated_rating_count'); + $table->json('alternative_names'); + $table->json('artworks'); + //$table->json('bundles'); + $table->integer('category');//enum + $table->uuid('checksum'); + $table->string('collection'); + $table->string('cover_id'); + $table->string('cover_image_path'); + $table->json('dlcs'); + //$table->json('expanded_games'); + $table->json('expansions'); + $table->json('external_games');//IDs on other Platforms + $table->date('first_release_date'); + //$table->integer('follows'); + //$table->json('forks'); + $table->string('franchise'); + $table->json('franchises'); + $table->json('game_engines'); + $table->json('game_localizations'); + $table->json('game_modes'); + $table->json('genres'); + //$table->integer('hypes'); + $table->json('involved_companies'); + $table->json('keywords'); + $table->json('language_supports'); + $table->json('multiplayer_modes'); + $table->string('name'); + $table->string('parent_game'); + $table->json('platforms'); + $table->json('player_perspectives'); + $table->json('ports'); + $table->string('rating');//formated double + //$table->integer('rating_count'); + $table->json('release_dates'); + $table->json('remakes'); + $table->json('remasters'); + $table->json('screenshots'); + $table->json('similar_games'); + $table->string('slug'); + $table->json('standalone_expansions'); + $table->integer('status');//enum + $table->text('storyline'); + $table->text('summary'); + $table->json('tags'); + $table->json('themes'); + $table->string('total_rating');//formated double + //$table->integer('total_rating_count'); + //$table->date('updated_at'); + $table->string('url');//IGDB Url + $table->string('version_parent'); + $table->string('version_title'); + $table->json('videos'); + $table->json('websites'); - $table->timestamps(); - }); + $table->timestamps(); + }); + } } /** @@ -79,6 +81,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('games'); + if (Schema::connection('pgsql_rauru')->hasTable('games')) { + Schema::connection('pgsql_rauru')->dropIfExists('games'); + } } }; diff --git a/database/migrations/2023_05_26_205735_create_mods_table.php b/database/migrations/2023_05_26_205735_create_mods_table.php index 3aed09c..93cec77 100644 --- a/database/migrations/2023_05_26_205735_create_mods_table.php +++ b/database/migrations/2023_05_26_205735_create_mods_table.php @@ -11,10 +11,12 @@ return new class extends Migration */ public function up(): void { - Schema::create('mods', function (Blueprint $table) { - $table->id(); - $table->timestamps(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('mods')) { + Schema::connection('pgsql_rauru')->create('mods', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + }); + } } /** @@ -22,6 +24,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('mods'); + if (Schema::connection('pgsql_rauru')->hasTable('mods')) { + Schema::connection('pgsql_rauru')->dropIfExists('mods'); + } } }; diff --git a/database/migrations/2023_05_26_205807_create_modpacks_table.php b/database/migrations/2023_05_26_205807_create_modpacks_table.php index 495608f..bd094ba 100644 --- a/database/migrations/2023_05_26_205807_create_modpacks_table.php +++ b/database/migrations/2023_05_26_205807_create_modpacks_table.php @@ -11,10 +11,12 @@ return new class extends Migration */ public function up(): void { - Schema::create('modpacks', function (Blueprint $table) { - $table->id(); - $table->timestamps(); - }); + if (!Schema::connection('pgsql_rauru')->hasTable('modpacks')) { + Schema::connection('pgsql_rauru')->create('modpacks', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + }); + } } /** @@ -22,6 +24,8 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('modpacks'); + if (Schema::connection('pgsql_rauru')->hasTable('modpacks')) { + Schema::connection('pgsql_rauru')->dropIfExists('modpacks'); + } } };