Skip to content

A self-hosted media server and file management system

feat: add uuid to series in prep for images

aminnausin2bcfaa2f7e80
diff --git a/app/Jobs/IndexFiles.php b/app/Jobs/IndexFiles.php
index 93245d79..d640d131 100755
--- a/app/Jobs/IndexFiles.php
+++ b/app/Jobs/IndexFiles.php
@@ -149,8 +149,9 @@ class IndexFiles extends ManagedSubTask {
foreach ($seriesEntries as $seriesChange) { // log series additions
$folderId = $seriesChange['folder_id'];
$compositeId = $seriesChange['composite_id'];
+ $uuid = $seriesChange['uuid'];
- $dbOut .= "INSERT INTO [series] VALUES ({$folderId}, {$compositeId});\n\n"; // insert
+ $dbOut .= "INSERT INTO [series] VALUES ({$folderId}, {$compositeId}, {$uuid});\n\n"; // insert
$seriesTransactions[] = $seriesChange;
}
@@ -202,7 +203,7 @@ class IndexFiles extends ManagedSubTask {
Category::insert($categoryTransactions);
Folder::insert($folderTransactions);
- Series::upsert($seriesTransactions, 'composite_id', ['folder_id']);
+ Series::upsert($seriesTransactions, 'composite_id', ['folder_id', 'uuid']);
Video::insert($videoTransactions);
Metadata::upsert($metadataTransactions, 'uuid', [
'video_id',
@@ -365,7 +366,7 @@ class IndexFiles extends ManagedSubTask {
unset($stored[$key]); // remove from stored
} else {
$generated = ['id' => $currentID, 'name' => $name, 'path' => $key, 'category_id' => $categoryStructure[$category], 'action' => 'INSERT'];
- $series = ['folder_id' => $currentID, 'composite_id' => $key];
+ $series = ['folder_id' => $currentID, 'composite_id' => $key, 'uuid' => Str::uuid()];
$current[$key] = ['id' => $currentID, 'last_scan' => -1]; // add to current
$changes[] = $generated;
$seriesChanges[] = $series; // add to new (insert)
diff --git a/app/Models/Series.php b/app/Models/Series.php
index 7d44bae6..e0a02e81 100644
--- a/app/Models/Series.php
+++ b/app/Models/Series.php
@@ -14,6 +14,7 @@ class Series extends Model {
/**
* id -> int8 (pk) (index)
+ * uuid -> uuid (unique) (index)
* folder_id -> int8 (fk) (nullable) (index)
* composite_id -> varchar(255) (index)
*
@@ -43,6 +44,7 @@ class Series extends Model {
* avg_intro_duration -> float(2) (default=90)
*/
protected $fillable = [
+ 'uuid',
'folder_id',
'editor_id',
'composite_id',
diff --git a/database/migrations/2026_05_29_020346_add_uuid_to_series.php b/database/migrations/2026_05_29_020346_add_uuid_to_series.php
new file mode 100644
index 00000000..ec794980
--- /dev/null
+++ b/database/migrations/2026_05_29_020346_add_uuid_to_series.php
@@ -0,0 +1,32 @@
+<?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 {
+ Schema::table('series', function (Blueprint $table) {
+ $table->uuid('uuid')->nullable()->unique()->after('id');
+ });
+
+ DB::statement('UPDATE series SET uuid = gen_random_uuid() WHERE uuid IS NULL');
+
+ Schema::table('series', function (Blueprint $table) {
+ $table->uuid('uuid')->nullable(false)->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('series', function (Blueprint $table) {
+ $table->dropColumn('uuid');
+ });
+ }
+};