mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-26 21:37:22 +08:00
migrations boolean() -> smallInteger()
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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('');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
@@ -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']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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'], );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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']);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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. 获取该表所有的索引信息
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (NexusDB::isPgsql()) {
|
||||
return;
|
||||
}
|
||||
$tableName = 'snatched';
|
||||
$columnNames = ['torrentid', 'userid'];
|
||||
// 1. 获取该表所有的索引信息
|
||||
|
||||
+5
-2
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
+1
-1
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
function mysql_connect($host, $username, $password, $database, $port)
|
||||
function mysql_connect($host, $username, $password, $database, $port, $driver = 'mysql')
|
||||
{
|
||||
return NexusDB::getInstance()->connect($host, $username, $password, $database, $port);
|
||||
return NexusDB::getInstance()->connect($host, $username, $password, $database, $port, $driver);
|
||||
}
|
||||
|
||||
function mysql_errno()
|
||||
|
||||
+30
-11
@@ -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
|
||||
|
||||
@@ -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 <code>%s</code> to <code>%s</code>, then insert into database', $tableRows[1]['label'], $tableRows[0]['label']);
|
||||
echo '</div>';
|
||||
if (!$mysqlInfo['match']) {
|
||||
echo sprintf('<div class="text-red-700 pt-10">MySQL version: %s is too low, please use the newest version of 5.7 or above.</div>', $mysqlInfo['version']);
|
||||
echo sprintf('<div class="text-red-700 pt-10">%s version: %s is too low, please use the newest version of %s or above.</div>', $mysqlInfo['dbType'], $mysqlInfo['version'], $mysqlInfo['minVersion']);
|
||||
}
|
||||
if (!$redisInfo['match']) {
|
||||
echo sprintf('<div class="text-red-700 pt-10">Redis version: %s is too low, please use 2.0.0 or above.</div>', $redisInfo['version']);
|
||||
echo sprintf('<div class="text-red-700 pt-10">Redis version: %s is too low, please use %s or above.</div>', $redisInfo['version'], $redisInfo['minVersion']);
|
||||
}
|
||||
} elseif ($currentStep == 5) {
|
||||
echo $install->renderForm($userFormControls, '1/2', '1/4', '3/4');
|
||||
|
||||
@@ -156,7 +156,7 @@ if ($currentStep == 4) {
|
||||
$symbolicLinks = $settingTableRows['symbolic_links'];
|
||||
$tableRows = $settingTableRows['table_rows'];
|
||||
$pass = $settingTableRows['pass'];
|
||||
$mysqlInfo = $update->getMysqlVersionInfo();
|
||||
$mysqlInfo = $update->getDatabaseVersionInfo();
|
||||
$redisInfo = $update->getRedisVersionInfo();
|
||||
while ($isPost) {
|
||||
set_time_limit(300);
|
||||
|
||||
Reference in New Issue
Block a user