diff --git a/app/Console/Commands/NexusUpdate.php b/app/Console/Commands/NexusUpdate.php
index 49bf3d99..445da237 100644
--- a/app/Console/Commands/NexusUpdate.php
+++ b/app/Console/Commands/NexusUpdate.php
@@ -108,7 +108,7 @@ class NexusUpdate extends Command
// $settings = $settingTableRows['settings'];
$symbolicLinks = $settingTableRows['symbolic_links'];
$fails = $settingTableRows['fails'];
- $mysqlInfo = $this->update->getMysqlVersionInfo();
+ $mysqlInfo = $this->update->getDatabaseVersionInfo();
$redisInfo = $this->update->getRedisVersionInfo();
if (!empty($fails)) {
diff --git a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php
index 7b93b406..7997ecb3 100644
--- a/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php
+++ b/database/migrations/2016_06_01_000001_create_oauth_auth_codes_table.php
@@ -16,7 +16,7 @@ return new class extends Migration
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('client_id');
$table->text('scopes')->nullable();
- $table->boolean('revoked');
+ $table->smallInteger('revoked');
$table->dateTime('expires_at')->nullable();
});
}
diff --git a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php
index 598798ee..ae458992 100644
--- a/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php
+++ b/database/migrations/2016_06_01_000002_create_oauth_access_tokens_table.php
@@ -17,7 +17,7 @@ return new class extends Migration
$table->unsignedBigInteger('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
- $table->boolean('revoked');
+ $table->smallInteger('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
});
diff --git a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php
index b007904c..f2891afd 100644
--- a/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php
+++ b/database/migrations/2016_06_01_000003_create_oauth_refresh_tokens_table.php
@@ -14,7 +14,7 @@ return new class extends Migration
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100)->index();
- $table->boolean('revoked');
+ $table->smallInteger('revoked');
$table->dateTime('expires_at')->nullable();
});
}
diff --git a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php b/database/migrations/2016_06_01_000004_create_oauth_clients_table.php
index 776ccfab..2c8683b4 100644
--- a/database/migrations/2016_06_01_000004_create_oauth_clients_table.php
+++ b/database/migrations/2016_06_01_000004_create_oauth_clients_table.php
@@ -18,9 +18,9 @@ return new class extends Migration
$table->string('secret', 100)->nullable();
$table->string('provider')->nullable();
$table->text('redirect');
- $table->boolean('personal_access_client');
- $table->boolean('password_client');
- $table->boolean('revoked');
+ $table->smallInteger('personal_access_client');
+ $table->smallInteger('password_client');
+ $table->smallInteger('revoked');
$table->timestamps();
});
}
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 eba73b78..39df9cca 100644
--- a/database/migrations/2021_06_08_113437_create_advertisements_table.php
+++ b/database/migrations/2021_06_08_113437_create_advertisements_table.php
@@ -18,7 +18,7 @@ class CreateAdvertisementsTable extends Migration
}
Schema::create('advertisements', function (Blueprint $table) {
$table->mediumIncrements('id');
- $table->boolean('enabled')->default(0);
+ $table->smallInteger('enabled')->default(0);
$table->enum('type', ['bbcodes', 'xhtml', 'text', 'image', 'flash']);
$table->enum('position', ['header', 'footer', 'belownav', 'belowsearchbox', 'torrentdetail', 'comment', 'interoverforums', 'forumpost', 'popup']);
$table->tinyInteger('displayorder')->default(0);
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 98cdd91c..bcd82b02 100644
--- a/database/migrations/2021_06_08_113437_create_attachments_table.php
+++ b/database/migrations/2021_06_08_113437_create_attachments_table.php
@@ -27,8 +27,8 @@ class CreateAttachmentsTable extends Migration
$table->unsignedBigInteger('filesize')->default(0);
$table->string('location')->default('');
$table->mediumInteger('downloads')->default(0);
- $table->boolean('isimage')->unsigned()->default(0);
- $table->boolean('thumb')->unsigned()->default(0);
+ $table->smallInteger('isimage')->unsigned()->default(0);
+ $table->smallInteger('thumb')->unsigned()->default(0);
$table->index(['userid', 'id'], 'pid');
$table->index(['added', 'isimage', 'downloads'], 'dateline');
});
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 58c7b451..6ecd13d5 100644
--- a/database/migrations/2021_06_08_113437_create_cheaters_table.php
+++ b/database/migrations/2021_06_08_113437_create_cheaters_table.php
@@ -28,7 +28,7 @@ class CreateCheatersTable extends Migration
$table->unsignedMediumInteger('leechers')->default(0);
$table->unsignedTinyInteger('hit')->default(0);
$table->unsignedMediumInteger('dealtby')->default(0);
- $table->boolean('dealtwith')->default(0);
+ $table->smallInteger('dealtwith')->default(0);
$table->string('comment')->default('');
});
}
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 0374b72f..023abec3 100644
--- a/database/migrations/2021_06_08_113437_create_friends_table.php
+++ b/database/migrations/2021_06_08_113437_create_friends_table.php
@@ -20,7 +20,7 @@ class CreateFriendsTable extends Migration
$table->increments('id');
$table->unsignedMediumInteger('userid')->default(0);
$table->unsignedMediumInteger('friendid')->default(0);
- $table->unique(['userid', 'friendid'], 'userfriend');
+ $table->unique(['userid', 'friendid']);
});
}
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 90feb222..035abec9 100644
--- a/database/migrations/2021_06_08_113437_create_news_table.php
+++ b/database/migrations/2021_06_08_113437_create_news_table.php
@@ -19,7 +19,7 @@ class CreateNewsTable extends Migration
Schema::create('news', function (Blueprint $table) {
$table->mediumIncrements('id');
$table->unsignedMediumInteger('userid')->default(0);
- $table->dateTime('added')->nullable()->index('added');
+ $table->dateTime('added')->nullable()->index();
$table->text('body')->nullable();
$table->string('title')->default('');
$table->enum('notify', ['yes', 'no'])->default('no');
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 af013693..c66fd988 100644
--- a/database/migrations/2021_06_08_113437_create_offers_table.php
+++ b/database/migrations/2021_06_08_113437_create_offers_table.php
@@ -18,7 +18,7 @@ class CreateOffersTable extends Migration
}
Schema::create('offers', function (Blueprint $table) {
$table->mediumIncrements('id');
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
$table->string('name', 225)->default('');
$table->text('descr')->nullable();
$table->dateTime('added')->nullable();
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 dbf7f43b..f36d6e66 100644
--- a/database/migrations/2021_06_08_113437_create_offervotes_table.php
+++ b/database/migrations/2021_06_08_113437_create_offervotes_table.php
@@ -19,7 +19,7 @@ class CreateOffervotesTable extends Migration
Schema::create('offervotes', function (Blueprint $table) {
$table->increments('id');
$table->unsignedMediumInteger('offerid')->default(0);
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
$table->enum('vote', ['yeah', 'against'])->default('yeah');
});
}
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 1ca3d479..8ab0eeab 100644
--- a/database/migrations/2021_06_08_113437_create_peers_table.php
+++ b/database/migrations/2021_06_08_113437_create_peers_table.php
@@ -36,7 +36,7 @@ class CreatePeersTable extends Migration
$table->unsignedBigInteger('downloadoffset')->default(0);
$table->unsignedBigInteger('uploadoffset')->default(0);
$table->char('passkey', 32)->default('');
- $table->unique(['torrent', 'peer_id']);
+ $table->unique(['torrent', 'peer_id', 'userid']);
});
}
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 40d5ae77..e70033b6 100644
--- a/database/migrations/2021_06_08_113437_create_pollanswers_table.php
+++ b/database/migrations/2021_06_08_113437_create_pollanswers_table.php
@@ -18,9 +18,9 @@ class CreatePollanswersTable extends Migration
}
Schema::create('pollanswers', function (Blueprint $table) {
$table->increments('id');
- $table->unsignedMediumInteger('pollid')->default(0)->index('pollid');
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
- $table->unsignedTinyInteger('selection')->default(0)->index('selection');
+ $table->unsignedMediumInteger('pollid')->default(0)->index();
+ $table->unsignedMediumInteger('userid')->default(0)->index();
+ $table->unsignedTinyInteger('selection')->default(0)->index();
});
}
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 1014ac3f..2313c229 100644
--- a/database/migrations/2021_06_08_113437_create_posts_table.php
+++ b/database/migrations/2021_06_08_113437_create_posts_table.php
@@ -19,13 +19,13 @@ class CreatePostsTable extends Migration
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->unsignedMediumInteger('topicid')->default(0);
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
- $table->dateTime('added')->nullable()->index('added');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
+ $table->dateTime('added')->nullable()->index();
$table->text('body')->nullable();
$table->text('ori_body')->nullable();
$table->unsignedMediumInteger('editedby')->default(0);
$table->dateTime('editdate')->nullable();
- $table->index(['topicid', 'id'], 'topicid_id');
+ $table->index(['topicid', 'id']);
});
}
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 009d403e..b1805fec 100644
--- a/database/migrations/2021_06_08_113437_create_readposts_table.php
+++ b/database/migrations/2021_06_08_113437_create_readposts_table.php
@@ -18,8 +18,8 @@ class CreateReadpostsTable extends Migration
}
Schema::create('readposts', function (Blueprint $table) {
$table->increments('id');
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
- $table->unsignedMediumInteger('topicid')->default(0)->index('topicid');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
+ $table->unsignedMediumInteger('topicid')->default(0)->index();
$table->unsignedInteger('lastpostread')->default(0);
});
}
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 d0ae1f1c..184c55fb 100644
--- a/database/migrations/2021_06_08_113437_create_reports_table.php
+++ b/database/migrations/2021_06_08_113437_create_reports_table.php
@@ -24,7 +24,7 @@ class CreateReportsTable extends Migration
$table->enum('type', ['torrent', 'user', 'offer', 'request', 'post', 'comment', 'subtitle'])->default('torrent');
$table->string('reason')->default('');
$table->unsignedMediumInteger('dealtby')->default(0);
- $table->boolean('dealtwith')->default(0);
+ $table->smallInteger('dealtwith')->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 4e708b02..625de461 100644
--- a/database/migrations/2021_06_08_113437_create_requests_table.php
+++ b/database/migrations/2021_06_08_113437_create_requests_table.php
@@ -18,7 +18,7 @@ class CreateRequestsTable extends Migration
}
Schema::create('requests', function (Blueprint $table) {
$table->increments('id');
- $table->unsignedInteger('userid')->default(0)->index('userid');
+ $table->unsignedInteger('userid')->default(0)->index();
$table->string('request', 225)->default('');
$table->text('descr');
$table->unsignedInteger('comments')->default(0);
@@ -31,7 +31,7 @@ class CreateRequestsTable extends Migration
$table->string('ori_descr')->default('');
$table->integer('ori_amount')->default(0);
$table->dateTime('added')->nullable();
- $table->index(['finish', 'userid'], 'finish, userid');
+ $table->index(['finish', 'userid']);
});
}
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 8a4a06b9..80de3541 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
@@ -23,7 +23,7 @@ class CreateSearchboxFieldsTable extends Migration
$table->integer('field_id')->default(0);
$table->timestamp('created_at')->useCurrent();
$table->timestamp('update_at')->useCurrent();
- $table->unique(['searchbox_id', 'field_type', 'field_id'], 'uniq_searchbox_type_id');
+ $table->unique(['searchbox_id', 'field_type', 'field_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 ac20b1d3..42242dec 100644
--- a/database/migrations/2021_06_08_113437_create_searchbox_table.php
+++ b/database/migrations/2021_06_08_113437_create_searchbox_table.php
@@ -19,14 +19,14 @@ class CreateSearchboxTable extends Migration
Schema::create('searchbox', function (Blueprint $table) {
$table->smallIncrements('id');
$table->string('name', 30)->nullable();
- $table->boolean('showsubcat')->default(0);
- $table->boolean('showsource')->default(0);
- $table->boolean('showmedium')->default(0);
- $table->boolean('showcodec')->default(0);
- $table->boolean('showstandard')->default(0);
- $table->boolean('showprocessing')->default(0);
- $table->boolean('showteam')->default(0);
- $table->boolean('showaudiocodec')->default(0);
+ $table->smallInteger('showsubcat')->default(0);
+ $table->smallInteger('showsource')->default(0);
+ $table->smallInteger('showmedium')->default(0);
+ $table->smallInteger('showcodec')->default(0);
+ $table->smallInteger('showstandard')->default(0);
+ $table->smallInteger('showprocessing')->default(0);
+ $table->smallInteger('showteam')->default(0);
+ $table->smallInteger('showaudiocodec')->default(0);
$table->unsignedSmallInteger('catsperrow')->default(7);
$table->unsignedSmallInteger('catpadding')->default(25);
$table->text('custom_fields')->nullable();
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 314188f0..82ac168c 100644
--- a/database/migrations/2021_06_08_113437_create_sitelog_table.php
+++ b/database/migrations/2021_06_08_113437_create_sitelog_table.php
@@ -18,7 +18,7 @@ class CreateSitelogTable extends Migration
}
Schema::create('sitelog', function (Blueprint $table) {
$table->increments('id');
- $table->dateTime('added')->nullable()->index('added');
+ $table->dateTime('added')->nullable()->index();
$table->text('txt');
$table->enum('security_level', ['normal', 'mod'])->default('normal');
});
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 75bc80b7..f4c10cf2 100644
--- a/database/migrations/2021_06_08_113437_create_snatched_table.php
+++ b/database/migrations/2021_06_08_113437_create_snatched_table.php
@@ -19,7 +19,7 @@ class CreateSnatchedTable extends Migration
Schema::create('snatched', function (Blueprint $table) {
$table->bigIncrements('id', true);
$table->unsignedMediumInteger('torrentid')->default(0);
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
$table->string('ip', 64)->default('');
$table->unsignedSmallInteger('port')->default(0);
$table->unsignedBigInteger('uploaded')->default(0);
@@ -31,7 +31,7 @@ class CreateSnatchedTable extends Migration
$table->dateTime('startdat')->nullable();
$table->dateTime('completedat')->nullable();
$table->enum('finished', ['yes', 'no'])->default('no');
- $table->unique(['torrentid', 'userid'], 'torrentid_userid');
+ $table->unique(['torrentid', 'userid']);
});
}
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 05a03ffd..4f1f9779 100644
--- a/database/migrations/2021_06_08_113437_create_staffmessages_table.php
+++ b/database/migrations/2021_06_08_113437_create_staffmessages_table.php
@@ -23,7 +23,7 @@ class CreateStaffmessagesTable extends Migration
$table->text('msg')->nullable();
$table->string('subject', 128)->default('');
$table->unsignedMediumInteger('answeredby')->default(0);
- $table->boolean('answered')->default(0);
+ $table->smallInteger('answered')->default(0);
$table->text('answer')->nullable();
});
}
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 64eac540..ba58c8c7 100644
--- a/database/migrations/2021_06_08_113437_create_topics_table.php
+++ b/database/migrations/2021_06_08_113437_create_topics_table.php
@@ -18,8 +18,8 @@ class CreateTopicsTable extends Migration
}
Schema::create('topics', function (Blueprint $table) {
$table->mediumIncrements('id');
- $table->unsignedMediumInteger('userid')->default(0)->index('userid');
- $table->string('subject', 128)->default('')->index('subject');
+ $table->unsignedMediumInteger('userid')->default(0)->index();
+ $table->string('subject', 128)->default('')->index();
$table->enum('locked', ['yes', 'no'])->default('no');
$table->unsignedSmallInteger('forumid')->default(0);
$table->unsignedInteger('firstpost')->default(0);
@@ -27,8 +27,8 @@ class CreateTopicsTable extends Migration
$table->enum('sticky', ['no', 'yes'])->default('no');
$table->unsignedTinyInteger('hlcolor')->default(0);
$table->unsignedInteger('views')->default(0);
- $table->index(['forumid', 'lastpost'], 'forumid_lastpost');
- $table->index(['forumid', 'sticky', 'lastpost'], 'forumid_sticky_lastpost');
+ $table->index(['forumid', 'lastpost'], );
+ $table->index(['forumid', 'sticky', 'lastpost'], );
});
}
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 c050686e..cd039bf9 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
@@ -18,8 +18,8 @@ class CreateTorrentSecretsTable extends Migration
}
Schema::create('torrent_secrets', function (Blueprint $table) {
$table->integer('id', true);
- $table->integer('uid')->index('idx_uid');
- $table->integer('torrent_id')->default(0)->index('idx_torrent_id');
+ $table->integer('uid')->index();
+ $table->integer('torrent_id')->default(0)->index();
$table->string('secret');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
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 cf68b2b2..606c2e03 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
@@ -18,16 +18,14 @@ class CreateTorrentsCustomFieldValuesTable extends Migration
}
Schema::create('torrents_custom_field_values', function (Blueprint $table) {
$table->integer('id', true);
- $table->integer('torrent_id')->default(0)->index('idx_torrent_id');
- $table->integer('custom_field_id')->default(0)->index('idx_field_id');
+ $table->integer('torrent_id')->default(0)->index();
+ $table->integer('custom_field_id')->default(0)->index();
$table->mediumText('custom_field_value')->nullable();
$table->dateTime('created_at');
$table->dateTime('updated_at');
});
if (\Nexus\Database\NexusDB::isMysql()) {
\Illuminate\Support\Facades\DB::statement('alter table torrents_custom_field_values add index(custom_field_value(191))');
- } else if (Nexus\Database\NexusDB::isPgsql()) {
- \Illuminate\Support\Facades\DB::statement('alter table torrents_custom_field_values left(custom_field_value,191)');
}
}
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 b6f93167..4764a494 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
@@ -18,8 +18,8 @@ class CreateUserBanLogsTable extends Migration
}
Schema::create('user_ban_logs', function (Blueprint $table) {
$table->bigInteger('id', true);
- $table->integer('uid')->default(0)->index('idx_uid');
- $table->string('username')->default('')->index('idx_username');
+ $table->integer('uid')->default(0)->index();
+ $table->string('username')->default('')->index();
$table->integer('operator')->default(0);
$table->string('reason')->nullable();
$table->timestamp('created_at')->nullable()->useCurrent();
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 d611c91a..05f0327f 100644
--- a/database/migrations/2021_06_08_113437_create_users_table.php
+++ b/database/migrations/2021_06_08_113437_create_users_table.php
@@ -22,14 +22,14 @@ class CreateUsersTable extends Migration
}
Schema::create('users', function (Blueprint $table) use ($uidStarts) {
$table->id('id')->startingValue($uidStarts);
- $table->string('username', 40)->default('')->unique('username');
+ $table->string('username', 40)->default('')->unique();
$table->string('passhash', 32)->default('');
$table->binary('secret');
$table->string('email', 80)->default('');
$table->enum('status', ['pending', 'confirmed'])->default('pending');
$table->dateTime('added')->nullable();
$table->dateTime('last_login')->nullable();
- $table->dateTime('last_access')->nullable()->index('last_access');
+ $table->dateTime('last_access')->nullable()->index();
$table->dateTime('last_home')->nullable();
$table->dateTime('last_offer')->nullable();
$table->dateTime('forum_access')->nullable();
@@ -48,25 +48,25 @@ class CreateUsersTable extends Migration
$table->text('info')->nullable();
$table->enum('acceptpms', ['yes', 'friends', 'no'])->default('yes');
$table->enum('commentpm', ['yes', 'no'])->default('yes');
- $table->string('ip', 64)->default('')->index('ip');
- $table->unsignedTinyInteger('class')->default(1)->index('class');
+ $table->string('ip', 64)->default('')->index();
+ $table->unsignedTinyInteger('class')->default(1)->index();
$table->tinyInteger('max_class_once')->default(1);
$table->string('avatar')->default('');
- $table->unsignedBigInteger('uploaded')->default(0)->index('uploaded');
- $table->unsignedBigInteger('downloaded')->default(0)->index('downloaded');
+ $table->unsignedBigInteger('uploaded')->default(0)->index();
+ $table->unsignedBigInteger('downloaded')->default(0)->index();
$table->unsignedBigInteger('seedtime')->default(0);
$table->unsignedBigInteger('leechtime')->default(0);
$table->string('title', 30)->default('');
- $table->unsignedSmallInteger('country')->default(107)->index('country');
+ $table->unsignedSmallInteger('country')->default(107)->index();
$table->string('notifs', 500)->nullable();
$table->text('modcomment')->nullable();
- $table->enum('enabled', ['yes', 'no'])->default('yes')->index('enabled');
+ $table->enum('enabled', ['yes', 'no'])->default('yes')->index();
$table->enum('avatars', ['yes', 'no'])->default('yes');
$table->enum('donor', ['yes', 'no'])->default('no');
$table->decimal('donated')->default(0.00);
$table->decimal('donated_cny')->default(0.00);
$table->dateTime('donoruntil')->nullable();
- $table->enum('warned', ['yes', 'no'])->default('no')->index('warned');
+ $table->enum('warned', ['yes', 'no'])->default('no')->index();
$table->dateTime('warneduntil')->nullable();
$table->enum('noad', ['yes', 'no'])->default('no');
$table->dateTime('noaduntil')->nullable();
@@ -84,7 +84,7 @@ class CreateUsersTable extends Migration
$table->string('supportfor')->default('');
$table->string('pickfor')->default('');
$table->string('supportlang', 50)->default('');
- $table->string('passkey', 32)->default('')->index('passkey');
+ $table->string('passkey', 32)->default('')->index();
$table->string('promotion_link', 32)->nullable();
$table->enum('uploadpos', ['yes', 'no'])->default('yes');
$table->enum('forumpost', ['yes', 'no'])->default('yes');
@@ -93,7 +93,7 @@ class CreateUsersTable extends Migration
$table->enum('signatures', ['yes', 'no'])->default('yes');
$table->string('signature', 800)->default('');
$table->unsignedSmallInteger('lang')->default(6);
- $table->smallInteger('cheat')->default(0)->index('cheat');
+ $table->smallInteger('cheat')->default(0)->index();
$table->unsignedInteger('download')->default(0);
$table->unsignedInteger('upload')->default(0);
$table->unsignedTinyInteger('isp')->default(0);
@@ -118,7 +118,7 @@ class CreateUsersTable extends Migration
$table->enum('showdescription', ['yes', 'no'])->nullable()->default('yes');
$table->enum('showcomment', ['yes', 'no'])->nullable()->default('yes');
$table->enum('showclienterror', ['yes', 'no'])->default('no');
- $table->boolean('showdlnotice')->default(1);
+ $table->smallInteger('showdlnotice')->default(1);
$table->enum('tooltip', ['minorimdb', 'medianimdb', 'off'])->default('off');
$table->enum('shownfo', ['yes', 'no'])->nullable()->default('yes');
$table->enum('timetype', ['timeadded', 'timealive'])->nullable()->default('timealive');
@@ -136,7 +136,7 @@ class CreateUsersTable extends Migration
$table->unsignedSmallInteger('school')->default(35);
$table->enum('showfb', ['yes', 'no'])->default('yes');
$table->string('page')->nullable()->default('');
- $table->index(['status', 'added'], 'status_added');
+ $table->index(['status', 'added']);
});
}
diff --git a/database/migrations/2022_04_18_030257_handle_peers_peer_id_unique.php b/database/migrations/2022_04_18_030257_handle_peers_peer_id_unique.php
index 7c134340..7eb66a87 100644
--- a/database/migrations/2022_04_18_030257_handle_peers_peer_id_unique.php
+++ b/database/migrations/2022_04_18_030257_handle_peers_peer_id_unique.php
@@ -14,6 +14,9 @@ return new class extends Migration
*/
public function up()
{
+ if (\Nexus\Database\NexusDB::isPgsql()) {
+ return;
+ }
$tableName = 'peers';
$columnNames = ['torrent', 'peer_id'];
// 1. 获取该表所有的索引信息
diff --git a/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php b/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php
index 7ea19c5d..377d9069 100644
--- a/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php
+++ b/database/migrations/2022_09_02_031539_add_extra_to_searchbox_table.php
@@ -14,7 +14,7 @@ return new class extends Migration
public function up()
{
Schema::table('searchbox', function (Blueprint $table) {
- $table->text('extra')->nullable();
+ $table->json('extra')->nullable();
});
}
diff --git a/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php b/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php
index 654cc1a8..99f442d7 100644
--- a/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php
+++ b/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php
@@ -14,7 +14,9 @@ return new class extends Migration
public function up()
{
Schema::table('searchbox', function (Blueprint $table) {
- $table->json('extra')->nullable()->change();
+ if (\Nexus\Database\NexusDB::isMysql()) {
+ $table->json('extra')->nullable()->change();
+ }
$table->string('custom_fields_display_name')->nullable(true)->default('')->change();
});
diff --git a/database/migrations/2023_03_29_021950_handle_snatched_user_torrent_unique.php b/database/migrations/2023_03_29_021950_handle_snatched_user_torrent_unique.php
index a607a597..f36c7279 100644
--- a/database/migrations/2023_03_29_021950_handle_snatched_user_torrent_unique.php
+++ b/database/migrations/2023_03_29_021950_handle_snatched_user_torrent_unique.php
@@ -15,6 +15,9 @@ return new class extends Migration
*/
public function up()
{
+ if (NexusDB::isPgsql()) {
+ return;
+ }
$tableName = 'snatched';
$columnNames = ['torrentid', 'userid'];
// 1. 获取该表所有的索引信息
diff --git a/database/migrations/2023_04_01_005409_add_unique_torrent_peer_user_to_peers_table.php b/database/migrations/2023_04_01_005409_add_unique_torrent_peer_user_to_peers_table.php
index 1c356171..06dd1a90 100644
--- a/database/migrations/2023_04_01_005409_add_unique_torrent_peer_user_to_peers_table.php
+++ b/database/migrations/2023_04_01_005409_add_unique_torrent_peer_user_to_peers_table.php
@@ -3,7 +3,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-use Illuminate\Support\Facades\DB;
+use Nexus\Database\NexusDB;
return new class extends Migration
{
@@ -14,10 +14,13 @@ return new class extends Migration
*/
public function up()
{
+ if (NexusDB::isPgsql()) {
+ return;
+ }
$tableName = 'peers';
$columnNames = ['torrent', 'peer_id', 'userid'];
// 1. 获取该表所有的索引信息
- $indexesToDelete = \Nexus\Database\NexusDB::listColumnIndexNames($tableName, $columnNames);
+ $indexesToDelete = NexusDB::listColumnIndexNames($tableName, $columnNames);
// 3. 执行删除操作
Schema::table($tableName, function (Blueprint $table) use ($indexesToDelete) {
diff --git a/database/migrations/2023_06_01_013150_change_bonus_log_table_value_decimal.php b/database/migrations/2023_06_01_013150_change_bonus_log_table_value_decimal.php
index cad57547..ebd4086b 100644
--- a/database/migrations/2023_06_01_013150_change_bonus_log_table_value_decimal.php
+++ b/database/migrations/2023_06_01_013150_change_bonus_log_table_value_decimal.php
@@ -14,7 +14,7 @@ return new class extends Migration
public function up()
{
Schema::table('users', function (Blueprint $table) {
- $table->decimal("seedbonus", 20, 1)->change();
+ $table->decimal("seedbonus", 20, 1)->default(0)->change();
});
Schema::table('bonus_logs', function (Blueprint $table) {
$table->decimal("old_total_value", 20, 1)->change();
diff --git a/database/migrations/2024_03_17_021209_add_skips_authorization_field_to_oauth_clients_table.php b/database/migrations/2024_03_17_021209_add_skips_authorization_field_to_oauth_clients_table.php
index 8b4daed5..84ec6906 100644
--- a/database/migrations/2024_03_17_021209_add_skips_authorization_field_to_oauth_clients_table.php
+++ b/database/migrations/2024_03_17_021209_add_skips_authorization_field_to_oauth_clients_table.php
@@ -14,7 +14,7 @@ return new class extends Migration
public function up()
{
Schema::table('oauth_clients', function (Blueprint $table) {
- $table->boolean("skips_authorization")->default(false);
+ $table->smallInteger("skips_authorization")->default(false);
});
}
diff --git a/database/migrations/2025_04_23_042250_create_oauth_providers_table.php b/database/migrations/2025_04_23_042250_create_oauth_providers_table.php
index f3ebde79..41fb1083 100644
--- a/database/migrations/2025_04_23_042250_create_oauth_providers_table.php
+++ b/database/migrations/2025_04_23_042250_create_oauth_providers_table.php
@@ -25,7 +25,7 @@ return new class extends Migration
$table->string('email_claim')->nullable();
$table->string('level_claim')->nullable();
$table->string('level_limit')->nullable();
- $table->boolean('enabled');
+ $table->smallInteger('enabled');
$table->integer('priority');
$table->timestamps();
});
diff --git a/include/functions.php b/include/functions.php
index eaf2683f..9623956d 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -5410,7 +5410,7 @@ function saveSetting(string $prefix, array $nameAndValue, string $autoload = 'ye
{
$prefix = strtolower($prefix);
$datetimeNow = date('Y-m-d H:i:s');
- $sql = "insert into `settings` (name, value, created_at, updated_at, autoload) values ";
+ $sql = "insert into settings (name, value, created_at, updated_at, autoload) values ";
$data = [];
foreach ($nameAndValue as $name => $value) {
if (is_array($value)) {
@@ -5418,7 +5418,14 @@ function saveSetting(string $prefix, array $nameAndValue, string $autoload = 'ye
}
$data[] = sprintf("(%s, %s, %s, %s, '%s')", sqlesc("$prefix.$name"), sqlesc($value), sqlesc($datetimeNow), sqlesc($datetimeNow), $autoload);
}
- $sql .= implode(",", $data) . " on duplicate key update value = values(value)";
+ $sql .= implode(",", $data);
+ if (\Nexus\Database\NexusDB::isMysql()) {
+ $sql .= " on duplicate key update value = values(value)";
+ } else if (\Nexus\Database\NexusDB::isPgsql()) {
+ $sql .= " on conflict (name) do update set value = EXCLUDED.value";
+ } else {
+ throw new \RuntimeException('Not supported database.');
+ }
\Nexus\Database\NexusDB::statement($sql);
clear_setting_cache();
do_action("nexus_setting_update");
diff --git a/nexus/Database/DBInterface.php b/nexus/Database/DBInterface.php
index 5f41457a..60048245 100644
--- a/nexus/Database/DBInterface.php
+++ b/nexus/Database/DBInterface.php
@@ -3,7 +3,7 @@ namespace Nexus\Database;
interface DBInterface
{
- public function connect($host, $username, $password, $database, $port);
+ public function connect($host, $username, $password, $database, $port, $driver = 'mysql');
public function query(string $sql);
@@ -29,4 +29,4 @@ interface DBInterface
public function freeResult($result);
-}
\ No newline at end of file
+}
diff --git a/nexus/Database/DBMysqli.php b/nexus/Database/DBMysqli.php
index 3e32dbee..6f7f9b64 100644
--- a/nexus/Database/DBMysqli.php
+++ b/nexus/Database/DBMysqli.php
@@ -10,7 +10,7 @@ class DBMysqli implements DBInterface
{
private $mysqli;
- public function connect($host, $username, $password, $database, $port)
+ public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
{
$mysqli = new \mysqli($host, $username, $password, $database, $port);
/* check connection */
diff --git a/nexus/Database/DBPdo.php b/nexus/Database/DBPdo.php
index 4f8e63f9..cdefeec9 100644
--- a/nexus/Database/DBPdo.php
+++ b/nexus/Database/DBPdo.php
@@ -8,10 +8,9 @@ class DBPdo implements DBInterface
private $driver;
private $lastStmt;
- public function connect($host, $username, $password, $database, $port)
+ public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
{
- $driver = $this->driver = nexus_config('nexus.database.default');
-
+ $this->driver = $driver;
if ($driver === 'mysql') {
$dsn = "mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4";
} elseif ($driver === 'pgsql') {
diff --git a/nexus/Database/NexusDB.php b/nexus/Database/NexusDB.php
index cdcead11..3f23df0d 100644
--- a/nexus/Database/NexusDB.php
+++ b/nexus/Database/NexusDB.php
@@ -63,9 +63,9 @@ class NexusDB
return self::$instance = $instance;
}
- public function connect($host, $username, $password, $database, $port)
+ public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
{
- $result = $this->driver->connect($host, $username, $password, $database, $port);
+ $result = $this->driver->connect($host, $username, $password, $database, $port, $driver);
if (!$result) {
throw new DatabaseException(sprintf('[%s]: %s', $this->errno(), $this->error()));
}
@@ -78,8 +78,9 @@ class NexusDB
if ($this->isConnected()) {
return null;
}
- $config = nexus_config('nexus.mysql');
- return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
+ $dbType = self::getConnectionName();
+ $config = nexus_config('nexus.database.connections.' . $dbType);
+ return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $dbType);
}
public function query(string $sql)
@@ -485,6 +486,4 @@ class NexusDB
return $indexesNames;
}
-
-
}
diff --git a/nexus/Database/helpers.php b/nexus/Database/helpers.php
index 51f33e7c..7324538e 100644
--- a/nexus/Database/helpers.php
+++ b/nexus/Database/helpers.php
@@ -1,9 +1,9 @@
connect($host, $username, $password, $database, $port);
+ return NexusDB::getInstance()->connect($host, $username, $password, $database, $port, $driver);
}
function mysql_errno()
diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php
index 17b4da1c..1ce04c54 100644
--- a/nexus/Install/Install.php
+++ b/nexus/Install/Install.php
@@ -36,7 +36,7 @@ class Install
protected array $requiredExtensions = [
'ctype', 'curl', 'fileinfo', 'json', 'mbstring', 'openssl', 'pdo_mysql', 'tokenizer', 'xml',
'mysqli', 'bcmath', 'redis', 'gd', 'gmp', 'Zend OPcache', 'pcntl', 'posix', 'sockets', 'zip', 'intl',
- 'sqlite3', 'pdo_sqlite'
+ 'sqlite3', 'pdo_sqlite', 'pdo_pgsql',
];
protected array $conflictExtensions = [
@@ -156,11 +156,18 @@ class Install
public function listExistsTable()
{
- $sql = 'show tables';
+ if (NexusDB::isMysql()) {
+ $schema = nexus_env('DB_DATABASE');
+ } else if (NexusDB::isPgsql()) {
+ $schema = 'public';
+ } else {
+ throw new \RuntimeException('Invalid DB_CONNECTION');
+ }
+ $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = '$schema'";
$res = sql_query($sql);
$data = [];
- while ($row = mysql_fetch_row($res)) {
- $data[] = $row[0];
+ while ($row = mysql_fetch_assoc($res)) {
+ $data[] = $row['table_name'];
}
return $data;
}
@@ -554,7 +561,8 @@ class Install
}
$this->doLog("[CREATE ENV] final newData: " . json_encode($newData));
unset($key, $value);
- mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], (int)$newData['DB_PORT']);
+ //check
+ mysql_connect($newData['DB_HOST'], $newData['DB_USERNAME'], $newData['DB_PASSWORD'], $newData['DB_DATABASE'], (int)$newData['DB_PORT'], $newData['DB_CONNECTION']);
$redis = new \Redis();
$redis->connect($newData['REDIS_HOST'], $newData['REDIS_PORT'] ?: 6379);
if (!empty($data['REDIS_PASSWORD'])) {
@@ -723,14 +731,25 @@ class Install
return $results;
}
- public function getMysqlVersionInfo(): array
+ public function getDatabaseVersionInfo(): array
{
- $sql = 'select version() as v';
- $result = NexusDB::select($sql);
- $version = $result[0]['v'];
- $minVersion = '5.7.8';
+ if (NexusDB::isMysql()) {
+ $sql = 'select version() as v';
+ $result = NexusDB::select($sql);
+ $version = $result[0]['v'];
+ $minVersion = '5.7.8';
+ $dbType = "mysql";
+ } else if (NexusDB::isPgsql()) {
+ $sql = 'SHOW server_version;';
+ $result = NexusDB::select($sql);
+ $version = $result[0]['server_version'];
+ $minVersion = '16.0';
+ $dbType = "pgsql";
+ } else {
+ throw new \RuntimeException('Not supported database.');
+ }
$match = version_compare($version, $minVersion, '>=');
- return compact('version', 'match', 'minVersion');
+ return compact('version', 'match', 'minVersion', 'dbType');
}
public function getRedisVersionInfo(): array
diff --git a/nexus/Install/install/install.php b/nexus/Install/install/install.php
index d311059e..20735a19 100644
--- a/nexus/Install/install/install.php
+++ b/nexus/Install/install/install.php
@@ -103,7 +103,7 @@ if ($currentStep == 4) {
$symbolicLinks = $settingTableRows['symbolic_links'];
$tableRows = $settingTableRows['table_rows'];
$pass = $settingTableRows['pass'];
- $mysqlInfo = $install->getMysqlVersionInfo();
+ $mysqlInfo = $install->getDatabaseVersionInfo();
$redisInfo = $install->getREdisVersionInfo();
while ($isPost) {
set_time_limit(300);
@@ -189,10 +189,10 @@ if (
echo sprintf('This step will merge %s to %s, then insert into database', $tableRows[1]['label'], $tableRows[0]['label']);
echo '';
if (!$mysqlInfo['match']) {
- echo sprintf('