Remove ishashed and dehashstatus columns

This commit is contained in:
DariusIII
2026-02-11 12:40:10 +01:00
parent 47ce4c69a7
commit cc0d7fca87
12 changed files with 102 additions and 27 deletions
@@ -0,0 +1,98 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Drop index and column from release_files table
Schema::table('release_files', function (Blueprint $table) {
if ($this->hasIndex('release_files', 'ix_releasefiles_ishashed')) {
$table->dropIndex('ix_releasefiles_ishashed');
}
if (Schema::hasColumn('release_files', 'ishashed')) {
$table->dropColumn('ishashed');
}
});
// Drop index and columns from releases table
Schema::table('releases', function (Blueprint $table) {
if ($this->hasIndex('releases', 'ix_releases_dehashstatus')) {
$table->dropIndex('ix_releases_dehashstatus');
}
if (Schema::hasColumn('releases', 'ishashed')) {
$table->dropColumn('ishashed');
}
if (Schema::hasColumn('releases', 'dehashstatus')) {
$table->dropColumn('dehashstatus');
}
});
// Remove dehash settings from settings table
DB::table('settings')->whereIn('name', ['dehash', 'dehash_timer'])->delete();
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Restore columns to release_files table
Schema::table('release_files', function (Blueprint $table) {
if (! Schema::hasColumn('release_files', 'ishashed')) {
$table->boolean('ishashed')->default(false)->after('size');
}
if (! $this->hasIndex('release_files', 'ix_releasefiles_ishashed')) {
$table->index('ishashed', 'ix_releasefiles_ishashed');
}
});
// Restore columns to releases table
Schema::table('releases', function (Blueprint $table) {
if (! Schema::hasColumn('releases', 'dehashstatus')) {
$table->tinyInteger('dehashstatus')->default(0)->after('audiostatus');
}
if (! Schema::hasColumn('releases', 'ishashed')) {
$table->boolean('ishashed')->default(false)->after('isrenamed');
}
if (! $this->hasIndex('releases', 'ix_releases_dehashstatus')) {
$table->index(['dehashstatus', 'ishashed'], 'ix_releases_dehashstatus');
}
});
// Restore dehash settings
DB::table('settings')->insert([
['name' => 'dehash', 'value' => '0', 'section' => 'site', 'subsection' => '', 'hint' => 'dehash'],
['name' => 'dehash_timer', 'value' => '30', 'section' => 'site', 'subsection' => '', 'hint' => 'dehash_timer'],
]);
}
/**
* Check if an index exists on a table.
*/
private function hasIndex(string $table, string $indexName): bool
{
$indexes = Schema::getIndexes($table);
foreach ($indexes as $index) {
if ($index['name'] === $indexName) {
return true;
}
}
return false;
}
};
-5
View File
@@ -812,13 +812,11 @@ CREATE TABLE `release_files` (
`releases_id` int(10) unsigned NOT NULL COMMENT 'FK to releases.id',
`name` varchar(255) NOT NULL DEFAULT '',
`size` bigint(20) unsigned NOT NULL DEFAULT 0,
`ishashed` tinyint(1) NOT NULL DEFAULT 0,
`crc32` varchar(255) NOT NULL DEFAULT '',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`passworded` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`releases_id`,`name`),
KEY `ix_releasefiles_ishashed` (`ishashed`),
CONSTRAINT `FK_rf_releases` FOREIGN KEY (`releases_id`) REFERENCES `releases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
DROP TABLE IF EXISTS `release_informs`;
@@ -912,12 +910,10 @@ CREATE TABLE `releases` (
`jpgstatus` tinyint(1) NOT NULL DEFAULT 0,
`videostatus` tinyint(1) NOT NULL DEFAULT 0,
`audiostatus` tinyint(1) NOT NULL DEFAULT 0,
`dehashstatus` tinyint(1) NOT NULL DEFAULT 0,
`reqidstatus` tinyint(1) NOT NULL DEFAULT 0,
`nzbstatus` tinyint(1) NOT NULL DEFAULT 0,
`iscategorized` tinyint(1) NOT NULL DEFAULT 0,
`isrenamed` tinyint(1) NOT NULL DEFAULT 0,
`ishashed` tinyint(1) NOT NULL DEFAULT 0,
`proc_pp` tinyint(1) NOT NULL DEFAULT 0,
`proc_sorter` tinyint(1) NOT NULL DEFAULT 0,
`proc_par2` tinyint(1) NOT NULL DEFAULT 0,
@@ -937,7 +933,6 @@ CREATE TABLE `releases` (
KEY `ix_releases_predb_id_searchname` (`predb_id`,`searchname`),
KEY `ix_releases_haspreview_passwordstatus` (`haspreview`,`passwordstatus`),
KEY `ix_releases_nfostatus` (`nfostatus`,`size`),
KEY `ix_releases_dehashstatus` (`dehashstatus`,`ishashed`),
KEY `ix_releases_name` (`name`),
KEY `ix_releases_guid` (`guid`),
KEY `ix_releases_videos_id` (`videos_id`),
-5
View File
@@ -812,13 +812,11 @@ CREATE TABLE `release_files` (
`releases_id` int(10) unsigned NOT NULL COMMENT 'FK to releases.id',
`name` varchar(255) NOT NULL DEFAULT '',
`size` bigint(20) unsigned NOT NULL DEFAULT 0,
`ishashed` tinyint(1) NOT NULL DEFAULT 0,
`crc32` varchar(255) NOT NULL DEFAULT '',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`passworded` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`releases_id`,`name`),
KEY `ix_releasefiles_ishashed` (`ishashed`),
CONSTRAINT `FK_rf_releases` FOREIGN KEY (`releases_id`) REFERENCES `releases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
DROP TABLE IF EXISTS `release_informs`;
@@ -912,12 +910,10 @@ CREATE TABLE `releases` (
`jpgstatus` tinyint(1) NOT NULL DEFAULT 0,
`videostatus` tinyint(1) NOT NULL DEFAULT 0,
`audiostatus` tinyint(1) NOT NULL DEFAULT 0,
`dehashstatus` tinyint(1) NOT NULL DEFAULT 0,
`reqidstatus` tinyint(1) NOT NULL DEFAULT 0,
`nzbstatus` tinyint(1) NOT NULL DEFAULT 0,
`iscategorized` tinyint(1) NOT NULL DEFAULT 0,
`isrenamed` tinyint(1) NOT NULL DEFAULT 0,
`ishashed` tinyint(1) NOT NULL DEFAULT 0,
`proc_pp` tinyint(1) NOT NULL DEFAULT 0,
`proc_sorter` tinyint(1) NOT NULL DEFAULT 0,
`proc_par2` tinyint(1) NOT NULL DEFAULT 0,
@@ -937,7 +933,6 @@ CREATE TABLE `releases` (
KEY `ix_releases_predb_id_searchname` (`predb_id`,`searchname`),
KEY `ix_releases_haspreview_passwordstatus` (`haspreview`,`passwordstatus`),
KEY `ix_releases_nfostatus` (`nfostatus`,`size`),
KEY `ix_releases_dehashstatus` (`dehashstatus`,`ishashed`),
KEY `ix_releases_name` (`name`),
KEY `ix_releases_guid` (`guid`),
KEY `ix_releases_videos_id` (`videos_id`),