From c771ff9ef1c50c1ec940e6786eb4a091d2476ba2 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Wed, 9 Jun 2021 15:11:02 +0800 Subject: [PATCH] migrations check if table exists --- .env.example | 1 + app/Repositories/ExamRepository.php | 47 +++++++++++++++---- ...01_create_personal_access_tokens_table.php | 3 ++ ...021_06_08_113437_create_adclicks_table.php | 3 ++ ...1_06_08_113437_create_adminpanel_table.php | 3 ++ ..._08_113437_create_advertisements_table.php | 3 ++ ...7_create_agent_allowed_exception_table.php | 3 ++ ...3437_create_agent_allowed_family_table.php | 3 ++ ...6_08_113437_create_allowedemails_table.php | 3 ++ ..._06_08_113437_create_attachments_table.php | 3 ++ ...1_06_08_113437_create_attendance_table.php | 3 ++ ..._06_08_113437_create_audiocodecs_table.php | 3 ++ .../2021_06_08_113437_create_avps_table.php | 3 ++ ...06_08_113437_create_bannedemails_table.php | 3 ++ .../2021_06_08_113437_create_bans_table.php | 3 ++ ...21_06_08_113437_create_bitbucket_table.php | 3 ++ .../2021_06_08_113437_create_blocks_table.php | 3 ++ ...21_06_08_113437_create_bookmarks_table.php | 3 ++ ...1_06_08_113437_create_categories_table.php | 3 ++ ...021_06_08_113437_create_caticons_table.php | 3 ++ ...021_06_08_113437_create_cheaters_table.php | 3 ++ ...21_06_08_113437_create_chronicle_table.php | 3 ++ .../2021_06_08_113437_create_codecs_table.php | 3 ++ ...021_06_08_113437_create_comments_table.php | 3 ++ ...21_06_08_113437_create_countries_table.php | 3 ++ ...6_08_113437_create_downloadspeed_table.php | 3 ++ ...6_08_113437_create_exam_progress_table.php | 3 ++ ...1_06_08_113437_create_exam_users_table.php | 3 ++ .../2021_06_08_113437_create_exams_table.php | 3 ++ ..._06_08_113437_create_failed_jobs_table.php | 3 ++ .../2021_06_08_113437_create_faq_table.php | 3 ++ .../2021_06_08_113437_create_files_table.php | 3 ++ ...21_06_08_113437_create_forummods_table.php | 3 ++ .../2021_06_08_113437_create_forums_table.php | 3 ++ ...2021_06_08_113437_create_friends_table.php | 3 ++ .../2021_06_08_113437_create_fun_table.php | 3 ++ .../2021_06_08_113437_create_funds_table.php | 3 ++ ...021_06_08_113437_create_funvotes_table.php | 3 ++ ...2021_06_08_113437_create_invites_table.php | 3 ++ .../2021_06_08_113437_create_iplog_table.php | 3 ++ .../2021_06_08_113437_create_isp_table.php | 3 ++ ...021_06_08_113437_create_language_table.php | 3 ++ .../2021_06_08_113437_create_links_table.php | 3 ++ ...21_06_08_113437_create_locations_table.php | 3 ++ ...6_08_113437_create_loginattempts_table.php | 3 ++ .../2021_06_08_113437_create_magic_table.php | 3 ++ .../2021_06_08_113437_create_media_table.php | 3 ++ ...021_06_08_113437_create_messages_table.php | 3 ++ ...021_06_08_113437_create_modpanel_table.php | 3 ++ .../2021_06_08_113437_create_news_table.php | 3 ++ .../2021_06_08_113437_create_offers_table.php | 3 ++ ...1_06_08_113437_create_offervotes_table.php | 3 ++ ...1_06_08_113437_create_overforums_table.php | 3 ++ .../2021_06_08_113437_create_peers_table.php | 3 ++ ...2021_06_08_113437_create_pmboxes_table.php | 3 ++ ..._06_08_113437_create_pollanswers_table.php | 3 ++ .../2021_06_08_113437_create_polls_table.php | 3 ++ .../2021_06_08_113437_create_posts_table.php | 3 ++ ..._06_08_113437_create_processings_table.php | 3 ++ ...6_08_113437_create_prolinkclicks_table.php | 3 ++ ...21_06_08_113437_create_readposts_table.php | 3 ++ ...21_06_08_113437_create_regimages_table.php | 3 ++ ...2021_06_08_113437_create_reports_table.php | 3 ++ ...021_06_08_113437_create_requests_table.php | 3 ++ .../2021_06_08_113437_create_resreq_table.php | 3 ++ .../2021_06_08_113437_create_rules_table.php | 3 ++ ...2021_06_08_113437_create_schools_table.php | 3 ++ ...8_113437_create_searchbox_fields_table.php | 3 ++ ...21_06_08_113437_create_searchbox_table.php | 3 ++ ..._06_08_113437_create_secondicons_table.php | 3 ++ ...021_06_08_113437_create_settings_table.php | 3 ++ ...021_06_08_113437_create_shoutbox_table.php | 3 ++ ...2021_06_08_113437_create_sitelog_table.php | 3 ++ ...021_06_08_113437_create_snatched_table.php | 3 ++ ...2021_06_08_113437_create_sources_table.php | 3 ++ ...6_08_113437_create_staffmessages_table.php | 3 ++ ...21_06_08_113437_create_standards_table.php | 3 ++ ..._06_08_113437_create_stylesheets_table.php | 3 ++ .../2021_06_08_113437_create_subs_table.php | 3 ++ ...2021_06_08_113437_create_suggest_table.php | 3 ++ ...1_06_08_113437_create_sysoppanel_table.php | 3 ++ .../2021_06_08_113437_create_teams_table.php | 3 ++ .../2021_06_08_113437_create_thanks_table.php | 3 ++ .../2021_06_08_113437_create_topics_table.php | 3 ++ ...08_113437_create_torrent_secrets_table.php | 3 ++ ...ate_torrents_custom_field_values_table.php | 3 ++ ...37_create_torrents_custom_fields_table.php | 3 ++ ..._08_113437_create_torrents_state_table.php | 3 ++ ...021_06_08_113437_create_torrents_table.php | 3 ++ ..._06_08_113437_create_uploadspeed_table.php | 3 ++ ...6_08_113437_create_user_ban_logs_table.php | 3 ++ .../2021_06_08_113437_create_users_table.php | 3 ++ include/globalfunctions.php | 26 +++++++++- nexus/Install/Install.php | 2 +- nexus/Install/install/install.php | 2 +- public/announce.php | 8 ++-- 96 files changed, 339 insertions(+), 17 deletions(-) diff --git a/.env.example b/.env.example index acd14437..e020b3b8 100644 --- a/.env.example +++ b/.env.example @@ -62,3 +62,4 @@ GOOGLE_DRIVE_REFRESH_TOKEN= GOOGLE_DRIVE_FOLDER_ID= GEOIP2_DATABASE= +EXAM_PROGRESS_UPDATE_PROBABILITY=60 diff --git a/app/Repositories/ExamRepository.php b/app/Repositories/ExamRepository.php index 6d1a711f..5b66163a 100644 --- a/app/Repositories/ExamRepository.php +++ b/app/Repositories/ExamRepository.php @@ -319,6 +319,16 @@ class ExamRepository extends BaseRepository ExamProgress::query()->insert($insert); do_log("[addProgress] " . nexus_json_encode($insert)); + /** + * Updating progress is more performance intensive and will only be done with a certain probability + */ + $probability = (int)nexus_env('EXAM_PROGRESS_UPDATE_PROBABILITY', 60); + $random = mt_rand(1, 100); + do_log("probability: $probability, random: $random"); + if ($random > $probability) { + do_log("[SKIP_UPDATE_PROGRESS], random: $random > probability: $probability", 'warning'); + return true; + } $examProgress = $this->calculateProgress($examUser); $examProgressFormatted = $this->getProgressFormatted($exam, $examProgress); $examNotPassed = array_filter($examProgressFormatted, function ($item) { @@ -452,31 +462,48 @@ class ExamRepository extends BaseRepository return false; } if ($exams->count() > 1) { - do_log("Valid and discovered exam more than 1.", "warning"); + do_log("Valid and discovered exam more than 1.", "error"); return false; } /** @var Exam $exam */ $exam = $exams->first(); + $filters = $exam->filters; + do_log("exam: {$exam->id}, filters: " . nexus_json_encode($filters)); $userTable = (new User())->getTable(); $examUserTable = (new ExamUser())->getTable(); $baseQuery = User::query() ->leftJoin($examUserTable, function (JoinClause $join) use ($examUserTable, $userTable) { - $join->on("$userTable.id", "=", "$examUserTable.uid") - ->on("$examUserTable.status", "=", DB::raw(ExamUser::STATUS_NORMAL)); + $join->on("$userTable.id", "=", "$examUserTable.uid"); }) - ->where('enabled', User::ENABLED_YES) - ->where('visible', User::STATUS_CONFIRMED) + ->where("$userTable.enabled", User::ENABLED_YES) + ->where("$userTable.status", User::STATUS_CONFIRMED) ->whereRaw("$examUserTable.id is null") ->selectRaw("$userTable.*") ->orderBy("$userTable.id", "asc"); + + if (empty($filters->classes)) { + do_log("{$exam->id} no classes."); + return false; + } else { + $baseQuery->whereIn("$userTable.class", $filters->classes); + } + if (empty($filters->register_time_range) || empty($filters->register_time_range[0]) || empty($filters->register_time_range[1])) { + do_log("{$exam->id} no register_time_range."); + return false; + } else { + $baseQuery->where("$userTable.added", ">=", Carbon::parse($filters->register_time_range[0])->toDateTimeString()) + ->where("$userTable.added", '<=', Carbon::parse($filters->register_time_range[1])->toDateTimeString()); + } + $size = 1000; $minId = 0; $result = 0; while (true) { $logPrefix = sprintf('[%s], exam: %s, size: %s', __FUNCTION__, $exam->id , $size); $users = (clone $baseQuery)->where("$userTable.id", ">", $minId)->limit($size)->get(); + do_log("$logPrefix, query: " . last_query() . ", counts: " . $users->count()); if ($users->isEmpty()) { - do_log("$logPrefix, no more data..." . last_query()); + do_log("no more data..."); break; } $insert = []; @@ -484,10 +511,10 @@ class ExamRepository extends BaseRepository foreach ($users as $user) { $minId = $user->id; $currentLogPrefix = sprintf("$logPrefix, user: %s", $user->id); - if (!$this->isExamMatchUser($exam, $user)) { - do_log("$currentLogPrefix, exam not match this user."); - continue; - } +// if (!$this->isExamMatchUser($exam, $user)) { +// do_log("$currentLogPrefix, exam not match this user."); +// continue; +// } $insert[] = [ 'uid' => $user->id, 'exam_id' => $exam->id, 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 3ce00023..19c936d5 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 @@ -13,6 +13,9 @@ class CreatePersonalAccessTokensTable extends Migration */ public function up() { + if (Schema::hasTable('personal_access_tokens')) { + return; + } Schema::create('personal_access_tokens', function (Blueprint $table) { $table->bigIncrements('id'); $table->morphs('tokenable'); diff --git a/database/migrations/2021_06_08_113437_create_adclicks_table.php b/database/migrations/2021_06_08_113437_create_adclicks_table.php index 97c553e0..cee01d21 100644 --- a/database/migrations/2021_06_08_113437_create_adclicks_table.php +++ b/database/migrations/2021_06_08_113437_create_adclicks_table.php @@ -13,6 +13,9 @@ class CreateAdclicksTable extends Migration */ public function up() { + if (Schema::hasTable('adclicks')) { + return; + } Schema::create('adclicks', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('adid')->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_adminpanel_table.php b/database/migrations/2021_06_08_113437_create_adminpanel_table.php index 7cc5a28d..7c236328 100644 --- a/database/migrations/2021_06_08_113437_create_adminpanel_table.php +++ b/database/migrations/2021_06_08_113437_create_adminpanel_table.php @@ -13,6 +13,9 @@ class CreateAdminpanelTable extends Migration */ public function up() { + if (Schema::hasTable('adminpanel')) { + return; + } Schema::create('adminpanel', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 128)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_advertisements_table.php b/database/migrations/2021_06_08_113437_create_advertisements_table.php index cfa5ec69..eba73b78 100644 --- a/database/migrations/2021_06_08_113437_create_advertisements_table.php +++ b/database/migrations/2021_06_08_113437_create_advertisements_table.php @@ -13,6 +13,9 @@ class CreateAdvertisementsTable extends Migration */ public function up() { + if (Schema::hasTable('advertisements')) { + return; + } Schema::create('advertisements', function (Blueprint $table) { $table->mediumIncrements('id'); $table->boolean('enabled')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_agent_allowed_exception_table.php b/database/migrations/2021_06_08_113437_create_agent_allowed_exception_table.php index 2c6cdcfa..e87ad270 100644 --- a/database/migrations/2021_06_08_113437_create_agent_allowed_exception_table.php +++ b/database/migrations/2021_06_08_113437_create_agent_allowed_exception_table.php @@ -13,6 +13,9 @@ class CreateAgentAllowedExceptionTable extends Migration */ public function up() { + if (Schema::hasTable('agent_allowed_exception')) { + return; + } Schema::create('agent_allowed_exception', function (Blueprint $table) { $table->unsignedTinyInteger('family_id')->default(0)->index('family_id'); $table->string('name', 100)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_agent_allowed_family_table.php b/database/migrations/2021_06_08_113437_create_agent_allowed_family_table.php index 0b5dc89a..f7c2038f 100644 --- a/database/migrations/2021_06_08_113437_create_agent_allowed_family_table.php +++ b/database/migrations/2021_06_08_113437_create_agent_allowed_family_table.php @@ -13,6 +13,9 @@ class CreateAgentAllowedFamilyTable extends Migration */ public function up() { + if (Schema::hasTable('agent_allowed_family')) { + return; + } Schema::create('agent_allowed_family', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('family', 50)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_allowedemails_table.php b/database/migrations/2021_06_08_113437_create_allowedemails_table.php index 71933611..e0179c70 100644 --- a/database/migrations/2021_06_08_113437_create_allowedemails_table.php +++ b/database/migrations/2021_06_08_113437_create_allowedemails_table.php @@ -13,6 +13,9 @@ class CreateAllowedemailsTable extends Migration */ public function up() { + if (Schema::hasTable('allowedemails')) { + return; + } Schema::create('allowedemails', function (Blueprint $table) { $table->integer('id', true); $table->mediumText('value'); diff --git a/database/migrations/2021_06_08_113437_create_attachments_table.php b/database/migrations/2021_06_08_113437_create_attachments_table.php index 78c62e22..98cdd91c 100644 --- a/database/migrations/2021_06_08_113437_create_attachments_table.php +++ b/database/migrations/2021_06_08_113437_create_attachments_table.php @@ -13,6 +13,9 @@ class CreateAttachmentsTable extends Migration */ public function up() { + if (Schema::hasTable('attachments')) { + return; + } Schema::create('attachments', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_attendance_table.php b/database/migrations/2021_06_08_113437_create_attendance_table.php index fbc61beb..ebf3d16e 100644 --- a/database/migrations/2021_06_08_113437_create_attendance_table.php +++ b/database/migrations/2021_06_08_113437_create_attendance_table.php @@ -13,6 +13,9 @@ class CreateAttendanceTable extends Migration */ public function up() { + if (Schema::hasTable('attendance')) { + return; + } Schema::create('attendance', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedInteger('uid')->default(0)->index('idx_uid'); diff --git a/database/migrations/2021_06_08_113437_create_audiocodecs_table.php b/database/migrations/2021_06_08_113437_create_audiocodecs_table.php index 82b34f0a..5ea3b30d 100644 --- a/database/migrations/2021_06_08_113437_create_audiocodecs_table.php +++ b/database/migrations/2021_06_08_113437_create_audiocodecs_table.php @@ -13,6 +13,9 @@ class CreateAudiocodecsTable extends Migration */ public function up() { + if (Schema::hasTable('audiocodecs')) { + return; + } Schema::create('audiocodecs', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_avps_table.php b/database/migrations/2021_06_08_113437_create_avps_table.php index 6c1d003f..40a7c4c1 100644 --- a/database/migrations/2021_06_08_113437_create_avps_table.php +++ b/database/migrations/2021_06_08_113437_create_avps_table.php @@ -13,6 +13,9 @@ class CreateAvpsTable extends Migration */ public function up() { + if (Schema::hasTable('avps')) { + return; + } Schema::create('avps', function (Blueprint $table) { $table->string('arg', 20)->default('')->primary(); $table->text('value_s'); diff --git a/database/migrations/2021_06_08_113437_create_bannedemails_table.php b/database/migrations/2021_06_08_113437_create_bannedemails_table.php index bd5182b8..090ef91b 100644 --- a/database/migrations/2021_06_08_113437_create_bannedemails_table.php +++ b/database/migrations/2021_06_08_113437_create_bannedemails_table.php @@ -13,6 +13,9 @@ class CreateBannedemailsTable extends Migration */ public function up() { + if (Schema::hasTable('bannedemails')) { + return; + } Schema::create('bannedemails', function (Blueprint $table) { $table->integer('id', true); $table->mediumText('value'); diff --git a/database/migrations/2021_06_08_113437_create_bans_table.php b/database/migrations/2021_06_08_113437_create_bans_table.php index 390d57a5..7919e7b3 100644 --- a/database/migrations/2021_06_08_113437_create_bans_table.php +++ b/database/migrations/2021_06_08_113437_create_bans_table.php @@ -13,6 +13,9 @@ class CreateBansTable extends Migration */ public function up() { + if (Schema::hasTable('bans')) { + return; + } Schema::create('bans', function (Blueprint $table) { $table->smallIncrements('id'); $table->dateTime('added')->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_bitbucket_table.php b/database/migrations/2021_06_08_113437_create_bitbucket_table.php index 29b56639..926e0262 100644 --- a/database/migrations/2021_06_08_113437_create_bitbucket_table.php +++ b/database/migrations/2021_06_08_113437_create_bitbucket_table.php @@ -13,6 +13,9 @@ class CreateBitbucketTable extends Migration */ public function up() { + if (Schema::hasTable('bitbucket')) { + return; + } Schema::create('bitbucket', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('owner')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_blocks_table.php b/database/migrations/2021_06_08_113437_create_blocks_table.php index acaffc89..1ea0c51d 100644 --- a/database/migrations/2021_06_08_113437_create_blocks_table.php +++ b/database/migrations/2021_06_08_113437_create_blocks_table.php @@ -13,6 +13,9 @@ class CreateBlocksTable extends Migration */ public function up() { + if (Schema::hasTable('blocks')) { + return; + } Schema::create('blocks', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_bookmarks_table.php b/database/migrations/2021_06_08_113437_create_bookmarks_table.php index 7c32513f..823dd5c7 100644 --- a/database/migrations/2021_06_08_113437_create_bookmarks_table.php +++ b/database/migrations/2021_06_08_113437_create_bookmarks_table.php @@ -13,6 +13,9 @@ class CreateBookmarksTable extends Migration */ public function up() { + if (Schema::hasTable('bookmarks')) { + return; + } Schema::create('bookmarks', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('torrentid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_categories_table.php b/database/migrations/2021_06_08_113437_create_categories_table.php index 345403af..58869ee8 100644 --- a/database/migrations/2021_06_08_113437_create_categories_table.php +++ b/database/migrations/2021_06_08_113437_create_categories_table.php @@ -13,6 +13,9 @@ class CreateCategoriesTable extends Migration */ public function up() { + if (Schema::hasTable('categories')) { + return; + } Schema::create('categories', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedTinyInteger('mode')->default(1); diff --git a/database/migrations/2021_06_08_113437_create_caticons_table.php b/database/migrations/2021_06_08_113437_create_caticons_table.php index 0d718cf2..f3b58888 100644 --- a/database/migrations/2021_06_08_113437_create_caticons_table.php +++ b/database/migrations/2021_06_08_113437_create_caticons_table.php @@ -13,6 +13,9 @@ class CreateCaticonsTable extends Migration */ public function up() { + if (Schema::hasTable('caticons')) { + return; + } Schema::create('caticons', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 64)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_cheaters_table.php b/database/migrations/2021_06_08_113437_create_cheaters_table.php index 2046bd9b..58c7b451 100644 --- a/database/migrations/2021_06_08_113437_create_cheaters_table.php +++ b/database/migrations/2021_06_08_113437_create_cheaters_table.php @@ -13,6 +13,9 @@ class CreateCheatersTable extends Migration */ public function up() { + if (Schema::hasTable('cheaters')) { + return; + } Schema::create('cheaters', function (Blueprint $table) { $table->mediumIncrements('id'); $table->dateTime('added')->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_chronicle_table.php b/database/migrations/2021_06_08_113437_create_chronicle_table.php index 06d25762..bfa67b39 100644 --- a/database/migrations/2021_06_08_113437_create_chronicle_table.php +++ b/database/migrations/2021_06_08_113437_create_chronicle_table.php @@ -13,6 +13,9 @@ class CreateChronicleTable extends Migration */ public function up() { + if (Schema::hasTable('chronicle')) { + return; + } Schema::create('chronicle', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_codecs_table.php b/database/migrations/2021_06_08_113437_create_codecs_table.php index a60e0c1d..75fb8c75 100644 --- a/database/migrations/2021_06_08_113437_create_codecs_table.php +++ b/database/migrations/2021_06_08_113437_create_codecs_table.php @@ -13,6 +13,9 @@ class CreateCodecsTable extends Migration */ public function up() { + if (Schema::hasTable('codecs')) { + return; + } Schema::create('codecs', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_comments_table.php b/database/migrations/2021_06_08_113437_create_comments_table.php index 2b3acf84..4ad2e000 100644 --- a/database/migrations/2021_06_08_113437_create_comments_table.php +++ b/database/migrations/2021_06_08_113437_create_comments_table.php @@ -13,6 +13,9 @@ class CreateCommentsTable extends Migration */ public function up() { + if (Schema::hasTable('comments')) { + return; + } Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('user')->default(0)->index('user'); diff --git a/database/migrations/2021_06_08_113437_create_countries_table.php b/database/migrations/2021_06_08_113437_create_countries_table.php index 6dd53362..0ab2a754 100644 --- a/database/migrations/2021_06_08_113437_create_countries_table.php +++ b/database/migrations/2021_06_08_113437_create_countries_table.php @@ -13,6 +13,9 @@ class CreateCountriesTable extends Migration */ public function up() { + if (Schema::hasTable('countries')) { + return; + } Schema::create('countries', function (Blueprint $table) { $table->smallIncrements('id'); $table->string('name', 50)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_downloadspeed_table.php b/database/migrations/2021_06_08_113437_create_downloadspeed_table.php index c5ccdfa2..fecbb030 100644 --- a/database/migrations/2021_06_08_113437_create_downloadspeed_table.php +++ b/database/migrations/2021_06_08_113437_create_downloadspeed_table.php @@ -13,6 +13,9 @@ class CreateDownloadspeedTable extends Migration */ public function up() { + if (Schema::hasTable('downloadspeed')) { + return; + } Schema::create('downloadspeed', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 50)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_exam_progress_table.php b/database/migrations/2021_06_08_113437_create_exam_progress_table.php index cde7643c..2530d092 100644 --- a/database/migrations/2021_06_08_113437_create_exam_progress_table.php +++ b/database/migrations/2021_06_08_113437_create_exam_progress_table.php @@ -13,6 +13,9 @@ class CreateExamProgressTable extends Migration */ public function up() { + if (Schema::hasTable('exam_progress')) { + return; + } Schema::create('exam_progress', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('exam_user_id')->index(); diff --git a/database/migrations/2021_06_08_113437_create_exam_users_table.php b/database/migrations/2021_06_08_113437_create_exam_users_table.php index caa606c0..16e17684 100644 --- a/database/migrations/2021_06_08_113437_create_exam_users_table.php +++ b/database/migrations/2021_06_08_113437_create_exam_users_table.php @@ -13,6 +13,9 @@ class CreateExamUsersTable extends Migration */ public function up() { + if (Schema::hasTable('exam_users')) { + return; + } Schema::create('exam_users', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('uid')->index(); diff --git a/database/migrations/2021_06_08_113437_create_exams_table.php b/database/migrations/2021_06_08_113437_create_exams_table.php index efabe263..30e84f0b 100644 --- a/database/migrations/2021_06_08_113437_create_exams_table.php +++ b/database/migrations/2021_06_08_113437_create_exams_table.php @@ -13,6 +13,9 @@ class CreateExamsTable extends Migration */ public function up() { + if (Schema::hasTable('exams')) { + return; + } Schema::create('exams', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); diff --git a/database/migrations/2021_06_08_113437_create_failed_jobs_table.php b/database/migrations/2021_06_08_113437_create_failed_jobs_table.php index e39723c7..8a4a3e96 100644 --- a/database/migrations/2021_06_08_113437_create_failed_jobs_table.php +++ b/database/migrations/2021_06_08_113437_create_failed_jobs_table.php @@ -13,6 +13,9 @@ class CreateFailedJobsTable extends Migration */ public function up() { + if (Schema::hasTable('failed_jobs')) { + return; + } Schema::create('failed_jobs', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('uuid')->unique(); diff --git a/database/migrations/2021_06_08_113437_create_faq_table.php b/database/migrations/2021_06_08_113437_create_faq_table.php index 357e9d82..8a3b7cdf 100644 --- a/database/migrations/2021_06_08_113437_create_faq_table.php +++ b/database/migrations/2021_06_08_113437_create_faq_table.php @@ -13,6 +13,9 @@ class CreateFaqTable extends Migration */ public function up() { + if (Schema::hasTable('faq')) { + return; + } Schema::create('faq', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedSmallInteger('link_id')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_files_table.php b/database/migrations/2021_06_08_113437_create_files_table.php index d4c8adce..9c8181ce 100644 --- a/database/migrations/2021_06_08_113437_create_files_table.php +++ b/database/migrations/2021_06_08_113437_create_files_table.php @@ -13,6 +13,9 @@ class CreateFilesTable extends Migration */ public function up() { + if (Schema::hasTable('files')) { + return; + } Schema::create('files', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('torrent')->default(0)->index('torrent'); diff --git a/database/migrations/2021_06_08_113437_create_forummods_table.php b/database/migrations/2021_06_08_113437_create_forummods_table.php index a520e5d3..0a4835b3 100644 --- a/database/migrations/2021_06_08_113437_create_forummods_table.php +++ b/database/migrations/2021_06_08_113437_create_forummods_table.php @@ -13,6 +13,9 @@ class CreateForummodsTable extends Migration */ public function up() { + if (Schema::hasTable('forummods')) { + return; + } Schema::create('forummods', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedSmallInteger('forumid')->default(0)->index('forumid'); diff --git a/database/migrations/2021_06_08_113437_create_forums_table.php b/database/migrations/2021_06_08_113437_create_forums_table.php index b10c173d..3c021b6b 100644 --- a/database/migrations/2021_06_08_113437_create_forums_table.php +++ b/database/migrations/2021_06_08_113437_create_forums_table.php @@ -13,6 +13,9 @@ class CreateForumsTable extends Migration */ public function up() { + if (Schema::hasTable('forums')) { + return; + } Schema::create('forums', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedSmallInteger('sort')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_friends_table.php b/database/migrations/2021_06_08_113437_create_friends_table.php index e8063535..0374b72f 100644 --- a/database/migrations/2021_06_08_113437_create_friends_table.php +++ b/database/migrations/2021_06_08_113437_create_friends_table.php @@ -13,6 +13,9 @@ class CreateFriendsTable extends Migration */ public function up() { + if (Schema::hasTable('friends')) { + return; + } Schema::create('friends', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_fun_table.php b/database/migrations/2021_06_08_113437_create_fun_table.php index 34bab498..80242ee2 100644 --- a/database/migrations/2021_06_08_113437_create_fun_table.php +++ b/database/migrations/2021_06_08_113437_create_fun_table.php @@ -13,6 +13,9 @@ class CreateFunTable extends Migration */ public function up() { + if (Schema::hasTable('fun')) { + return; + } Schema::create('fun', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_funds_table.php b/database/migrations/2021_06_08_113437_create_funds_table.php index c83c3286..206819ed 100644 --- a/database/migrations/2021_06_08_113437_create_funds_table.php +++ b/database/migrations/2021_06_08_113437_create_funds_table.php @@ -13,6 +13,9 @@ class CreateFundsTable extends Migration */ public function up() { + if (Schema::hasTable('funds')) { + return; + } Schema::create('funds', function (Blueprint $table) { $table->increments('id'); $table->decimal('usd')->default(0.00); diff --git a/database/migrations/2021_06_08_113437_create_funvotes_table.php b/database/migrations/2021_06_08_113437_create_funvotes_table.php index 9f0d7f6f..582f495b 100644 --- a/database/migrations/2021_06_08_113437_create_funvotes_table.php +++ b/database/migrations/2021_06_08_113437_create_funvotes_table.php @@ -13,6 +13,9 @@ class CreateFunvotesTable extends Migration */ public function up() { + if (Schema::hasTable('funvotes')) { + return; + } Schema::create('funvotes', function (Blueprint $table) { $table->unsignedMediumInteger('funid'); $table->unsignedMediumInteger('userid'); diff --git a/database/migrations/2021_06_08_113437_create_invites_table.php b/database/migrations/2021_06_08_113437_create_invites_table.php index a918b905..eab743c3 100644 --- a/database/migrations/2021_06_08_113437_create_invites_table.php +++ b/database/migrations/2021_06_08_113437_create_invites_table.php @@ -13,6 +13,9 @@ class CreateInvitesTable extends Migration */ public function up() { + if (Schema::hasTable('invites')) { + return; + } Schema::create('invites', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('inviter')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_iplog_table.php b/database/migrations/2021_06_08_113437_create_iplog_table.php index b19caf41..624b947b 100644 --- a/database/migrations/2021_06_08_113437_create_iplog_table.php +++ b/database/migrations/2021_06_08_113437_create_iplog_table.php @@ -13,6 +13,9 @@ class CreateIplogTable extends Migration */ public function up() { + if (Schema::hasTable('iplog')) { + return; + } Schema::create('iplog', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('ip', 64)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_isp_table.php b/database/migrations/2021_06_08_113437_create_isp_table.php index da7c154e..a4d9fff7 100644 --- a/database/migrations/2021_06_08_113437_create_isp_table.php +++ b/database/migrations/2021_06_08_113437_create_isp_table.php @@ -13,6 +13,9 @@ class CreateIspTable extends Migration */ public function up() { + if (Schema::hasTable('isp')) { + return; + } Schema::create('isp', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 50)->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_language_table.php b/database/migrations/2021_06_08_113437_create_language_table.php index f0a88fdc..ea030fad 100644 --- a/database/migrations/2021_06_08_113437_create_language_table.php +++ b/database/migrations/2021_06_08_113437_create_language_table.php @@ -13,6 +13,9 @@ class CreateLanguageTable extends Migration */ public function up() { + if (Schema::hasTable('language')) { + return; + } Schema::create('language', function (Blueprint $table) { $table->smallIncrements('id'); $table->string('lang_name', 50)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_links_table.php b/database/migrations/2021_06_08_113437_create_links_table.php index 515d8193..78a90a65 100644 --- a/database/migrations/2021_06_08_113437_create_links_table.php +++ b/database/migrations/2021_06_08_113437_create_links_table.php @@ -13,6 +13,9 @@ class CreateLinksTable extends Migration */ public function up() { + if (Schema::hasTable('links')) { + return; + } Schema::create('links', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_locations_table.php b/database/migrations/2021_06_08_113437_create_locations_table.php index 8e8eac4c..8c7a78d7 100644 --- a/database/migrations/2021_06_08_113437_create_locations_table.php +++ b/database/migrations/2021_06_08_113437_create_locations_table.php @@ -13,6 +13,9 @@ class CreateLocationsTable extends Migration */ public function up() { + if (Schema::hasTable('locations')) { + return; + } Schema::create('locations', function (Blueprint $table) { $table->increments('id'); $table->string('name', 50)->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_loginattempts_table.php b/database/migrations/2021_06_08_113437_create_loginattempts_table.php index 50e9d4aa..a7ba8fee 100644 --- a/database/migrations/2021_06_08_113437_create_loginattempts_table.php +++ b/database/migrations/2021_06_08_113437_create_loginattempts_table.php @@ -13,6 +13,9 @@ class CreateLoginattemptsTable extends Migration */ public function up() { + if (Schema::hasTable('loginattempts')) { + return; + } Schema::create('loginattempts', function (Blueprint $table) { $table->increments('id'); $table->string('ip', 64)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_magic_table.php b/database/migrations/2021_06_08_113437_create_magic_table.php index 507ada4c..27cce0b6 100644 --- a/database/migrations/2021_06_08_113437_create_magic_table.php +++ b/database/migrations/2021_06_08_113437_create_magic_table.php @@ -13,6 +13,9 @@ class CreateMagicTable extends Migration */ public function up() { + if (Schema::hasTable('magic')) { + return; + } Schema::create('magic', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('torrentid')->default(0)->index('idx_torrentid'); diff --git a/database/migrations/2021_06_08_113437_create_media_table.php b/database/migrations/2021_06_08_113437_create_media_table.php index 1da55be6..fa99830e 100644 --- a/database/migrations/2021_06_08_113437_create_media_table.php +++ b/database/migrations/2021_06_08_113437_create_media_table.php @@ -13,6 +13,9 @@ class CreateMediaTable extends Migration */ public function up() { + if (Schema::hasTable('media')) { + return; + } Schema::create('media', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_messages_table.php b/database/migrations/2021_06_08_113437_create_messages_table.php index 65c56749..f91490e9 100644 --- a/database/migrations/2021_06_08_113437_create_messages_table.php +++ b/database/migrations/2021_06_08_113437_create_messages_table.php @@ -13,6 +13,9 @@ class CreateMessagesTable extends Migration */ public function up() { + if (Schema::hasTable('messages')) { + return; + } Schema::create('messages', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('sender')->default(0)->index('sender'); diff --git a/database/migrations/2021_06_08_113437_create_modpanel_table.php b/database/migrations/2021_06_08_113437_create_modpanel_table.php index 23ea3dbd..1e133dc5 100644 --- a/database/migrations/2021_06_08_113437_create_modpanel_table.php +++ b/database/migrations/2021_06_08_113437_create_modpanel_table.php @@ -13,6 +13,9 @@ class CreateModpanelTable extends Migration */ public function up() { + if (Schema::hasTable('modpanel')) { + return; + } Schema::create('modpanel', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 128)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_news_table.php b/database/migrations/2021_06_08_113437_create_news_table.php index be4a42aa..90feb222 100644 --- a/database/migrations/2021_06_08_113437_create_news_table.php +++ b/database/migrations/2021_06_08_113437_create_news_table.php @@ -13,6 +13,9 @@ class CreateNewsTable extends Migration */ public function up() { + if (Schema::hasTable('news')) { + return; + } Schema::create('news', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_offers_table.php b/database/migrations/2021_06_08_113437_create_offers_table.php index 12885a5b..af013693 100644 --- a/database/migrations/2021_06_08_113437_create_offers_table.php +++ b/database/migrations/2021_06_08_113437_create_offers_table.php @@ -13,6 +13,9 @@ class CreateOffersTable extends Migration */ public function up() { + if (Schema::hasTable('offers')) { + return; + } Schema::create('offers', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0)->index('userid'); diff --git a/database/migrations/2021_06_08_113437_create_offervotes_table.php b/database/migrations/2021_06_08_113437_create_offervotes_table.php index b387eb3c..dbf7f43b 100644 --- a/database/migrations/2021_06_08_113437_create_offervotes_table.php +++ b/database/migrations/2021_06_08_113437_create_offervotes_table.php @@ -13,6 +13,9 @@ class CreateOffervotesTable extends Migration */ public function up() { + if (Schema::hasTable('offervotes')) { + return; + } Schema::create('offervotes', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('offerid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_overforums_table.php b/database/migrations/2021_06_08_113437_create_overforums_table.php index ae752865..f5365fd8 100644 --- a/database/migrations/2021_06_08_113437_create_overforums_table.php +++ b/database/migrations/2021_06_08_113437_create_overforums_table.php @@ -13,6 +13,9 @@ class CreateOverforumsTable extends Migration */ public function up() { + if (Schema::hasTable('overforums')) { + return; + } Schema::create('overforums', function (Blueprint $table) { $table->smallIncrements('id'); $table->string('name', 60)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_peers_table.php b/database/migrations/2021_06_08_113437_create_peers_table.php index 60a9b08b..2019f0dd 100644 --- a/database/migrations/2021_06_08_113437_create_peers_table.php +++ b/database/migrations/2021_06_08_113437_create_peers_table.php @@ -13,6 +13,9 @@ class CreatePeersTable extends Migration */ public function up() { + if (Schema::hasTable('peers')) { + return; + } Schema::create('peers', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('torrent')->default(0)->index('torrent'); diff --git a/database/migrations/2021_06_08_113437_create_pmboxes_table.php b/database/migrations/2021_06_08_113437_create_pmboxes_table.php index 8843df4c..ab1c71bc 100644 --- a/database/migrations/2021_06_08_113437_create_pmboxes_table.php +++ b/database/migrations/2021_06_08_113437_create_pmboxes_table.php @@ -13,6 +13,9 @@ class CreatePmboxesTable extends Migration */ public function up() { + if (Schema::hasTable('pmboxes')) { + return; + } Schema::create('pmboxes', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_pollanswers_table.php b/database/migrations/2021_06_08_113437_create_pollanswers_table.php index 00618c47..40d5ae77 100644 --- a/database/migrations/2021_06_08_113437_create_pollanswers_table.php +++ b/database/migrations/2021_06_08_113437_create_pollanswers_table.php @@ -13,6 +13,9 @@ class CreatePollanswersTable extends Migration */ public function up() { + if (Schema::hasTable('pollanswers')) { + return; + } Schema::create('pollanswers', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('pollid')->default(0)->index('pollid'); diff --git a/database/migrations/2021_06_08_113437_create_polls_table.php b/database/migrations/2021_06_08_113437_create_polls_table.php index 1ce29365..08a78eba 100644 --- a/database/migrations/2021_06_08_113437_create_polls_table.php +++ b/database/migrations/2021_06_08_113437_create_polls_table.php @@ -13,6 +13,9 @@ class CreatePollsTable extends Migration */ public function up() { + if (Schema::hasTable('polls')) { + return; + } Schema::create('polls', function (Blueprint $table) { $table->mediumIncrements('id'); $table->dateTime('added')->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_posts_table.php b/database/migrations/2021_06_08_113437_create_posts_table.php index 82af140a..3af9bfb5 100644 --- a/database/migrations/2021_06_08_113437_create_posts_table.php +++ b/database/migrations/2021_06_08_113437_create_posts_table.php @@ -13,6 +13,9 @@ class CreatePostsTable extends Migration */ public function up() { + if (Schema::hasTable('posts')) { + return; + } Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('topicid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_processings_table.php b/database/migrations/2021_06_08_113437_create_processings_table.php index bd725f08..41d55583 100644 --- a/database/migrations/2021_06_08_113437_create_processings_table.php +++ b/database/migrations/2021_06_08_113437_create_processings_table.php @@ -13,6 +13,9 @@ class CreateProcessingsTable extends Migration */ public function up() { + if (Schema::hasTable('processings')) { + return; + } Schema::create('processings', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_prolinkclicks_table.php b/database/migrations/2021_06_08_113437_create_prolinkclicks_table.php index b12e7688..3086dcaa 100644 --- a/database/migrations/2021_06_08_113437_create_prolinkclicks_table.php +++ b/database/migrations/2021_06_08_113437_create_prolinkclicks_table.php @@ -13,6 +13,9 @@ class CreateProlinkclicksTable extends Migration */ public function up() { + if (Schema::hasTable('prolinkclicks')) { + return; + } Schema::create('prolinkclicks', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_readposts_table.php b/database/migrations/2021_06_08_113437_create_readposts_table.php index ce305844..009d403e 100644 --- a/database/migrations/2021_06_08_113437_create_readposts_table.php +++ b/database/migrations/2021_06_08_113437_create_readposts_table.php @@ -13,6 +13,9 @@ class CreateReadpostsTable extends Migration */ public function up() { + if (Schema::hasTable('readposts')) { + return; + } Schema::create('readposts', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('userid')->default(0)->index('userid'); diff --git a/database/migrations/2021_06_08_113437_create_regimages_table.php b/database/migrations/2021_06_08_113437_create_regimages_table.php index 63064568..fe7b90f0 100644 --- a/database/migrations/2021_06_08_113437_create_regimages_table.php +++ b/database/migrations/2021_06_08_113437_create_regimages_table.php @@ -13,6 +13,9 @@ class CreateRegimagesTable extends Migration */ public function up() { + if (Schema::hasTable('regimages')) { + return; + } Schema::create('regimages', function (Blueprint $table) { $table->mediumIncrements('id'); $table->string('imagehash', 32)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_reports_table.php b/database/migrations/2021_06_08_113437_create_reports_table.php index d1fa9661..d0ae1f1c 100644 --- a/database/migrations/2021_06_08_113437_create_reports_table.php +++ b/database/migrations/2021_06_08_113437_create_reports_table.php @@ -13,6 +13,9 @@ class CreateReportsTable extends Migration */ public function up() { + if (Schema::hasTable('reports')) { + return; + } Schema::create('reports', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('addedby')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_requests_table.php b/database/migrations/2021_06_08_113437_create_requests_table.php index b5cfc7cf..4e708b02 100644 --- a/database/migrations/2021_06_08_113437_create_requests_table.php +++ b/database/migrations/2021_06_08_113437_create_requests_table.php @@ -13,6 +13,9 @@ class CreateRequestsTable extends Migration */ public function up() { + if (Schema::hasTable('requests')) { + return; + } Schema::create('requests', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('userid')->default(0)->index('userid'); diff --git a/database/migrations/2021_06_08_113437_create_resreq_table.php b/database/migrations/2021_06_08_113437_create_resreq_table.php index 57b0654a..79bc683b 100644 --- a/database/migrations/2021_06_08_113437_create_resreq_table.php +++ b/database/migrations/2021_06_08_113437_create_resreq_table.php @@ -13,6 +13,9 @@ class CreateResreqTable extends Migration */ public function up() { + if (Schema::hasTable('resreq')) { + return; + } Schema::create('resreq', function (Blueprint $table) { $table->integer('id', true); $table->integer('reqid')->default(0)->index('reqid'); diff --git a/database/migrations/2021_06_08_113437_create_rules_table.php b/database/migrations/2021_06_08_113437_create_rules_table.php index fd6868cf..870bd1eb 100644 --- a/database/migrations/2021_06_08_113437_create_rules_table.php +++ b/database/migrations/2021_06_08_113437_create_rules_table.php @@ -13,6 +13,9 @@ class CreateRulesTable extends Migration */ public function up() { + if (Schema::hasTable('rules')) { + return; + } Schema::create('rules', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedSmallInteger('lang_id')->default(6); diff --git a/database/migrations/2021_06_08_113437_create_schools_table.php b/database/migrations/2021_06_08_113437_create_schools_table.php index d97d2449..46cea738 100644 --- a/database/migrations/2021_06_08_113437_create_schools_table.php +++ b/database/migrations/2021_06_08_113437_create_schools_table.php @@ -13,6 +13,9 @@ class CreateSchoolsTable extends Migration */ public function up() { + if (Schema::hasTable('schools')) { + return; + } Schema::create('schools', function (Blueprint $table) { $table->smallIncrements('id'); $table->string('name', 50)->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_searchbox_fields_table.php b/database/migrations/2021_06_08_113437_create_searchbox_fields_table.php index 7666e903..8a4a06b9 100644 --- a/database/migrations/2021_06_08_113437_create_searchbox_fields_table.php +++ b/database/migrations/2021_06_08_113437_create_searchbox_fields_table.php @@ -13,6 +13,9 @@ class CreateSearchboxFieldsTable extends Migration */ public function up() { + if (Schema::hasTable('searchbox_fields')) { + return; + } Schema::create('searchbox_fields', function (Blueprint $table) { $table->integer('id', true); $table->integer('searchbox_id'); diff --git a/database/migrations/2021_06_08_113437_create_searchbox_table.php b/database/migrations/2021_06_08_113437_create_searchbox_table.php index 9a3f4b88..ac20b1d3 100644 --- a/database/migrations/2021_06_08_113437_create_searchbox_table.php +++ b/database/migrations/2021_06_08_113437_create_searchbox_table.php @@ -13,6 +13,9 @@ class CreateSearchboxTable extends Migration */ public function up() { + if (Schema::hasTable('searchbox')) { + return; + } Schema::create('searchbox', function (Blueprint $table) { $table->smallIncrements('id'); $table->string('name', 30)->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_secondicons_table.php b/database/migrations/2021_06_08_113437_create_secondicons_table.php index c23d7a9e..1627689f 100644 --- a/database/migrations/2021_06_08_113437_create_secondicons_table.php +++ b/database/migrations/2021_06_08_113437_create_secondicons_table.php @@ -13,6 +13,9 @@ class CreateSecondiconsTable extends Migration */ public function up() { + if (Schema::hasTable('secondicons')) { + return; + } Schema::create('secondicons', function (Blueprint $table) { $table->smallIncrements('id'); $table->unsignedTinyInteger('source')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_settings_table.php b/database/migrations/2021_06_08_113437_create_settings_table.php index 496cb83d..c6baac35 100644 --- a/database/migrations/2021_06_08_113437_create_settings_table.php +++ b/database/migrations/2021_06_08_113437_create_settings_table.php @@ -13,6 +13,9 @@ class CreateSettingsTable extends Migration */ public function up() { + if (Schema::hasTable('settings')) { + return; + } Schema::create('settings', function (Blueprint $table) { $table->integer('id', true); $table->string('name')->default('')->unique('uniqe_name'); diff --git a/database/migrations/2021_06_08_113437_create_shoutbox_table.php b/database/migrations/2021_06_08_113437_create_shoutbox_table.php index 1d0fa2ce..8c2c7c11 100644 --- a/database/migrations/2021_06_08_113437_create_shoutbox_table.php +++ b/database/migrations/2021_06_08_113437_create_shoutbox_table.php @@ -13,6 +13,9 @@ class CreateShoutboxTable extends Migration */ public function up() { + if (Schema::hasTable('shoutbox')) { + return; + } Schema::create('shoutbox', function (Blueprint $table) { $table->integer('id', true); $table->unsignedMediumInteger('userid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_sitelog_table.php b/database/migrations/2021_06_08_113437_create_sitelog_table.php index cd3046f5..314188f0 100644 --- a/database/migrations/2021_06_08_113437_create_sitelog_table.php +++ b/database/migrations/2021_06_08_113437_create_sitelog_table.php @@ -13,6 +13,9 @@ class CreateSitelogTable extends Migration */ public function up() { + if (Schema::hasTable('sitelog')) { + return; + } Schema::create('sitelog', function (Blueprint $table) { $table->increments('id'); $table->dateTime('added')->nullable()->index('added'); diff --git a/database/migrations/2021_06_08_113437_create_snatched_table.php b/database/migrations/2021_06_08_113437_create_snatched_table.php index cd575320..b9d205d9 100644 --- a/database/migrations/2021_06_08_113437_create_snatched_table.php +++ b/database/migrations/2021_06_08_113437_create_snatched_table.php @@ -13,6 +13,9 @@ class CreateSnatchedTable extends Migration */ public function up() { + if (Schema::hasTable('snatched')) { + return; + } Schema::create('snatched', function (Blueprint $table) { $table->integer('id', true); $table->unsignedMediumInteger('torrentid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_sources_table.php b/database/migrations/2021_06_08_113437_create_sources_table.php index 37ad656d..d7badcdf 100644 --- a/database/migrations/2021_06_08_113437_create_sources_table.php +++ b/database/migrations/2021_06_08_113437_create_sources_table.php @@ -13,6 +13,9 @@ class CreateSourcesTable extends Migration */ public function up() { + if (Schema::hasTable('sources')) { + return; + } Schema::create('sources', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_staffmessages_table.php b/database/migrations/2021_06_08_113437_create_staffmessages_table.php index 14b5aba9..05a03ffd 100644 --- a/database/migrations/2021_06_08_113437_create_staffmessages_table.php +++ b/database/migrations/2021_06_08_113437_create_staffmessages_table.php @@ -13,6 +13,9 @@ class CreateStaffmessagesTable extends Migration */ public function up() { + if (Schema::hasTable('staffmessages')) { + return; + } Schema::create('staffmessages', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('sender')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_standards_table.php b/database/migrations/2021_06_08_113437_create_standards_table.php index 8f17ccb8..b68816cb 100644 --- a/database/migrations/2021_06_08_113437_create_standards_table.php +++ b/database/migrations/2021_06_08_113437_create_standards_table.php @@ -13,6 +13,9 @@ class CreateStandardsTable extends Migration */ public function up() { + if (Schema::hasTable('standards')) { + return; + } Schema::create('standards', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_stylesheets_table.php b/database/migrations/2021_06_08_113437_create_stylesheets_table.php index 422c52cf..1c1414ad 100644 --- a/database/migrations/2021_06_08_113437_create_stylesheets_table.php +++ b/database/migrations/2021_06_08_113437_create_stylesheets_table.php @@ -13,6 +13,9 @@ class CreateStylesheetsTable extends Migration */ public function up() { + if (Schema::hasTable('stylesheets')) { + return; + } Schema::create('stylesheets', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('uri')->default(''); diff --git a/database/migrations/2021_06_08_113437_create_subs_table.php b/database/migrations/2021_06_08_113437_create_subs_table.php index 293208c2..460c4989 100644 --- a/database/migrations/2021_06_08_113437_create_subs_table.php +++ b/database/migrations/2021_06_08_113437_create_subs_table.php @@ -13,6 +13,9 @@ class CreateSubsTable extends Migration */ public function up() { + if (Schema::hasTable('subs')) { + return; + } Schema::create('subs', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('torrent_id')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_suggest_table.php b/database/migrations/2021_06_08_113437_create_suggest_table.php index b407222c..7ca30a4d 100644 --- a/database/migrations/2021_06_08_113437_create_suggest_table.php +++ b/database/migrations/2021_06_08_113437_create_suggest_table.php @@ -13,6 +13,9 @@ class CreateSuggestTable extends Migration */ public function up() { + if (Schema::hasTable('suggest')) { + return; + } Schema::create('suggest', function (Blueprint $table) { $table->increments('id'); $table->string('keywords')->default('')->index('keywords'); diff --git a/database/migrations/2021_06_08_113437_create_sysoppanel_table.php b/database/migrations/2021_06_08_113437_create_sysoppanel_table.php index 5c9e9c42..80abdf7f 100644 --- a/database/migrations/2021_06_08_113437_create_sysoppanel_table.php +++ b/database/migrations/2021_06_08_113437_create_sysoppanel_table.php @@ -13,6 +13,9 @@ class CreateSysoppanelTable extends Migration */ public function up() { + if (Schema::hasTable('sysoppanel')) { + return; + } Schema::create('sysoppanel', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 128)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_teams_table.php b/database/migrations/2021_06_08_113437_create_teams_table.php index d3f2387e..0f975e51 100644 --- a/database/migrations/2021_06_08_113437_create_teams_table.php +++ b/database/migrations/2021_06_08_113437_create_teams_table.php @@ -13,6 +13,9 @@ class CreateTeamsTable extends Migration */ public function up() { + if (Schema::hasTable('teams')) { + return; + } Schema::create('teams', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 30)->default(''); diff --git a/database/migrations/2021_06_08_113437_create_thanks_table.php b/database/migrations/2021_06_08_113437_create_thanks_table.php index 61decd26..1e8dec14 100644 --- a/database/migrations/2021_06_08_113437_create_thanks_table.php +++ b/database/migrations/2021_06_08_113437_create_thanks_table.php @@ -13,6 +13,9 @@ class CreateThanksTable extends Migration */ public function up() { + if (Schema::hasTable('thanks')) { + return; + } Schema::create('thanks', function (Blueprint $table) { $table->increments('id'); $table->unsignedMediumInteger('torrentid')->default(0); diff --git a/database/migrations/2021_06_08_113437_create_topics_table.php b/database/migrations/2021_06_08_113437_create_topics_table.php index 38329bfd..64eac540 100644 --- a/database/migrations/2021_06_08_113437_create_topics_table.php +++ b/database/migrations/2021_06_08_113437_create_topics_table.php @@ -13,6 +13,9 @@ class CreateTopicsTable extends Migration */ public function up() { + if (Schema::hasTable('topics')) { + return; + } Schema::create('topics', function (Blueprint $table) { $table->mediumIncrements('id'); $table->unsignedMediumInteger('userid')->default(0)->index('userid'); diff --git a/database/migrations/2021_06_08_113437_create_torrent_secrets_table.php b/database/migrations/2021_06_08_113437_create_torrent_secrets_table.php index 3f59d0bd..c050686e 100644 --- a/database/migrations/2021_06_08_113437_create_torrent_secrets_table.php +++ b/database/migrations/2021_06_08_113437_create_torrent_secrets_table.php @@ -13,6 +13,9 @@ class CreateTorrentSecretsTable extends Migration */ public function up() { + if (Schema::hasTable('torrent_secrets')) { + return; + } Schema::create('torrent_secrets', function (Blueprint $table) { $table->integer('id', true); $table->integer('uid')->index('idx_uid'); diff --git a/database/migrations/2021_06_08_113437_create_torrents_custom_field_values_table.php b/database/migrations/2021_06_08_113437_create_torrents_custom_field_values_table.php index 6d23d12e..6e91e999 100644 --- a/database/migrations/2021_06_08_113437_create_torrents_custom_field_values_table.php +++ b/database/migrations/2021_06_08_113437_create_torrents_custom_field_values_table.php @@ -13,6 +13,9 @@ class CreateTorrentsCustomFieldValuesTable extends Migration */ public function up() { + if (Schema::hasTable('torrents_custom_field_values')) { + return; + } Schema::create('torrents_custom_field_values', function (Blueprint $table) { $table->integer('id', true); $table->integer('torrent_id')->default(0)->index('idx_torrent_id'); diff --git a/database/migrations/2021_06_08_113437_create_torrents_custom_fields_table.php b/database/migrations/2021_06_08_113437_create_torrents_custom_fields_table.php index 47367f7a..9635dff3 100644 --- a/database/migrations/2021_06_08_113437_create_torrents_custom_fields_table.php +++ b/database/migrations/2021_06_08_113437_create_torrents_custom_fields_table.php @@ -13,6 +13,9 @@ class CreateTorrentsCustomFieldsTable extends Migration */ public function up() { + if (Schema::hasTable('torrents_custom_fields')) { + return; + } Schema::create('torrents_custom_fields', function (Blueprint $table) { $table->integer('id', true); $table->string('name')->default(''); diff --git a/database/migrations/2021_06_08_113437_create_torrents_state_table.php b/database/migrations/2021_06_08_113437_create_torrents_state_table.php index 6505ffb2..d7e221f3 100644 --- a/database/migrations/2021_06_08_113437_create_torrents_state_table.php +++ b/database/migrations/2021_06_08_113437_create_torrents_state_table.php @@ -13,6 +13,9 @@ class CreateTorrentsStateTable extends Migration */ public function up() { + if (Schema::hasTable('torrents_state')) { + return; + } Schema::create('torrents_state', function (Blueprint $table) { $table->unsignedTinyInteger('global_sp_state')->default(1); }); diff --git a/database/migrations/2021_06_08_113437_create_torrents_table.php b/database/migrations/2021_06_08_113437_create_torrents_table.php index c7c6a9a8..f23dc5d9 100644 --- a/database/migrations/2021_06_08_113437_create_torrents_table.php +++ b/database/migrations/2021_06_08_113437_create_torrents_table.php @@ -13,6 +13,9 @@ class CreateTorrentsTable extends Migration */ public function up() { + if (Schema::hasTable('torrents')) { + return; + } Schema::create('torrents', function (Blueprint $table) { $table->mediumIncrements('id'); $table->binary('info_hash')->unique('info_hash'); diff --git a/database/migrations/2021_06_08_113437_create_uploadspeed_table.php b/database/migrations/2021_06_08_113437_create_uploadspeed_table.php index 2e97591c..4e8ff022 100644 --- a/database/migrations/2021_06_08_113437_create_uploadspeed_table.php +++ b/database/migrations/2021_06_08_113437_create_uploadspeed_table.php @@ -13,6 +13,9 @@ class CreateUploadspeedTable extends Migration */ public function up() { + if (Schema::hasTable('uploadspeed')) { + return; + } Schema::create('uploadspeed', function (Blueprint $table) { $table->tinyIncrements('id'); $table->string('name', 50)->nullable(); diff --git a/database/migrations/2021_06_08_113437_create_user_ban_logs_table.php b/database/migrations/2021_06_08_113437_create_user_ban_logs_table.php index 05a5a847..b6f93167 100644 --- a/database/migrations/2021_06_08_113437_create_user_ban_logs_table.php +++ b/database/migrations/2021_06_08_113437_create_user_ban_logs_table.php @@ -13,6 +13,9 @@ class CreateUserBanLogsTable extends Migration */ public function up() { + if (Schema::hasTable('user_ban_logs')) { + return; + } Schema::create('user_ban_logs', function (Blueprint $table) { $table->bigInteger('id', true); $table->integer('uid')->default(0)->index('idx_uid'); diff --git a/database/migrations/2021_06_08_113437_create_users_table.php b/database/migrations/2021_06_08_113437_create_users_table.php index 75edd808..444fc4d7 100644 --- a/database/migrations/2021_06_08_113437_create_users_table.php +++ b/database/migrations/2021_06_08_113437_create_users_table.php @@ -13,6 +13,9 @@ class CreateUsersTable extends Migration */ public function up() { + if (Schema::hasTable('users')) { + return; + } Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('username', 40)->default('')->unique('username'); diff --git a/include/globalfunctions.php b/include/globalfunctions.php index f8e5b7d2..884767e5 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -155,11 +155,35 @@ function nexus_dd($vars) */ function do_log($log, $level = 'info') { + static $uid, $passkey, $env, $sequence, $setLogLevel; + if (is_null($setLogLevel)) { + $setLogLevel = nexus_env('LOG_LEVEL', 'debug'); + } + $logLevels = [ + \Psr\Log\LogLevel::DEBUG, + \Psr\Log\LogLevel::INFO, + \Psr\Log\LogLevel::NOTICE, + \Psr\Log\LogLevel::WARNING, + \Psr\Log\LogLevel::ERROR, + \Psr\Log\LogLevel::CRITICAL, + \Psr\Log\LogLevel::ALERT, + \Psr\Log\LogLevel::EMERGENCY, + ]; + $setLogLevelKey = array_search($setLogLevel, $logLevels); + $currentLogLevelKey = array_search($level, $logLevels); + if ($currentLogLevelKey === false) { + $level = \Psr\log\LogLevel::ERROR; + $log = "[ERROR_LOG_LEVEL] $log"; + $currentLogLevelKey = array_search($level, $logLevels); + } + if ($currentLogLevelKey < $setLogLevelKey) { + return; + } + $logFile = getLogFile(); if (($fd = fopen($logFile, 'a')) === false) { $fd = fopen(sys_get_temp_dir() . '/nexus.log', 'a'); } - static $uid, $passkey, $env, $sequence; if (is_null($uid)) { $sequence = 0; if (IN_NEXUS) { diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index 5925a90a..a3fee013 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -106,7 +106,7 @@ class Install $filename = basename($path); $count = preg_match('/create_(.*)_table.php/', $filename, $matches); if ($count) { - $tables[$matches[1]] = ''; + $tables[$matches[1]] = $filename; } } return $tables; diff --git a/nexus/Install/install/install.php b/nexus/Install/install/install.php index 0513d9d5..514e8c63 100644 --- a/nexus/Install/install/install.php +++ b/nexus/Install/install/install.php @@ -62,7 +62,7 @@ if ($currentStep == 3) { try { // $install->createTable($shouldCreateTable); if (!WITH_LARAVEL) { - throw new \RuntimeException('Larvel is not avaliable.'); + throw new \RuntimeException('Laravel is not avaliable.'); } $command = "php " . ROOT_PATH . "artisan install:migrate"; $result = exec($command, $output, $result_code); diff --git a/public/announce.php b/public/announce.php index 977fd06d..93751a1c 100644 --- a/public/announce.php +++ b/public/announce.php @@ -81,7 +81,7 @@ $seeder = ($left == 0) ? "yes" : "no"; if (!$az = $Cache->get_value('user_passkey_'.$passkey.'_content')){ $res = sql_query("SELECT id, downloadpos, enabled, uploaded, downloaded, class, parked, clientselect, showclienterror,passkey FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1"); $az = $currentUser = mysql_fetch_array($res); - do_log("[check passkey], currentUser: " . nexus_json_encode($currentUser)); + do_log("[check passkey], currentUser: " . nexus_json_encode($currentUser), 'error'); $Cache->cache_value('user_passkey_'.$passkey.'_content', $az, 950); } if (!$az) err("Invalid passkey! Re-download the .torrent from $BASEURL"); @@ -117,8 +117,8 @@ if (!$torrent) { $start = strpos($queryString, $firstNeedle) + strlen($firstNeedle); $end = strpos($queryString, "&", $start); $infoHashUrlEncode = substr($queryString, $start, $end - $start); - do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString"); - do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode"); + do_log("[TORRENT NOT EXISTS] $checkTorrentSql, params: $queryString", 'error'); + do_log("[TORRENT NOT EXISTS] infoHashUrlEncode: $infoHashUrlEncode", 'error'); err("torrent not registered with this tracker"); } @@ -471,7 +471,7 @@ $examRep = new \App\Repositories\ExamRepository(); try { $examRep->addProgress($userid, $torrentid, $examIndexData); } catch (\Exception $exception) { - do_log("add exam progress fail: " . $exception->getMessage()); + do_log("add exam progress fail: " . $exception->getMessage(), 'critical'); } benc_resp($rep_dict);