mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 04:20:49 +08:00
user add last_announce_at/seeding_torrent_count/seeding_torrent_size
This commit is contained in:
@@ -13,20 +13,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableFields = [
|
||||
'comments' => ['editdate'],
|
||||
'invites' => ['time_invited'],
|
||||
'offers' => ['allowedtime'],
|
||||
'peers' => ['last_action', 'prev_action'],
|
||||
'posts' => ['editdate'],
|
||||
'snatched' => ['last_action', 'completedat'],
|
||||
'torrents' => ['last_action', 'promotion_until', 'picktime', 'last_reseed'],
|
||||
'users' => [
|
||||
'last_login', 'last_access', 'last_home', 'last_offer', 'forum_access', 'last_staffmsg',
|
||||
'last_pm', 'last_comment', 'last_post', 'donoruntil', 'warneduntil', 'noaduntil', 'vip_until',
|
||||
'leechwarnuntil', 'lastwarned',
|
||||
],
|
||||
];
|
||||
$tableFields = \App\Repositories\UpgradeRepository::DATETIME_INVALID_VALUE_FIELDS;
|
||||
|
||||
foreach ($tableFields as $table => $fields) {
|
||||
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer("seeding_torrent_count")->default(0);
|
||||
$table->bigInteger("seeding_torrent_size")->default(0);
|
||||
$table->dateTime("last_announce_at")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn("seeding_torrent_count", "seeding_torrent_size", "last_announce_at");
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$tableFields = \App\Repositories\UpgradeRepository::DATETIME_INVALID_VALUE_FIELDS;
|
||||
|
||||
foreach ($tableFields as $table => $fields) {
|
||||
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo($table);
|
||||
foreach ($fields as $field) {
|
||||
if (isset($columnInfo[$field]) && $columnInfo[$field]['DATA_TYPE'] == 'datetime') {
|
||||
\Illuminate\Support\Facades\DB::statement("update $table set $field = null where $field = '0000-00-00 00:00:00'");
|
||||
}
|
||||
}
|
||||
}
|
||||
$columnInfo = \Nexus\Database\NexusDB::getMysqlColumnInfo("snatched");
|
||||
if (isset($columnInfo["finish_ip"])) {
|
||||
\Illuminate\Support\Facades\DB::statement("alter table snatched drop column finish_ip");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user