A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: storyboard and image tables
aminnausin2e696094ea94
diff --git a/app/Models/Image.php b/app/Models/Image.phpnew file mode 100644index 00000000..7799161b--- /dev/null+++ b/app/Models/Image.php@@ -0,0 +1,35 @@+<?php++namespace App\Models;++use App\Enums\ImageSource;+use App\Enums\ImageType;+use Illuminate\Database\Eloquent\Model;++class Image extends Model {+ /**+ * id -> int8 (pk)+ * metadata_uuid -> int8 (fk) (index) (onDelete=cascade)+ *+ * user_id -> int8 (fk) (nullable) (onDelete=setNull)+ *+ * image_type -> int2 (enum) (composite index with metadata_uuid, is_primary)+ * source -> int2 (enum)+ * is_primary -> boolean (default=false)+ *+ * width -> int4 (nullable)+ * height -> int4 (nullable)+ * blurhash -> varchar(64)+ *+ * path -> text (nullable)+ * source_url -> text (nullable)+ *+ * created_at -> timestamptz (nullable)+ * updated_at -> timestamptz (nullable)+ */+ protected $casts = [+ 'image_type' => ImageType::class,+ 'source' => ImageSource::class,+ 'is_primary' => 'boolean',+ ];+}diff --git a/app/Models/Metadata.php b/app/Models/Metadata.phpindex f38c3606..fbfee026 100644--- a/app/Models/Metadata.php+++ b/app/Models/Metadata.php@@ -155,6 +155,14 @@ class Metadata extends Model {return $this->hasMany(Subtitle::class, 'metadata_uuid', 'uuid')->orderBy('track_id');}+ public function images(): HasMany {+ return $this->hasMany(Image::class, 'metadata_uuid', 'uuid')->orderBy('track_id');+ }++ public function storyBoard(): HasOne {+ return $this->hasOne(Storyboard::class, 'metadata_uuid', 'uuid');+ }+public function syncViewCountToRecords(): void {$actual = $this->records()->count();self::where('id', $this->id)diff --git a/app/Models/Storyboard.php b/app/Models/Storyboard.phpnew file mode 100644index 00000000..16242651--- /dev/null+++ b/app/Models/Storyboard.php@@ -0,0 +1,27 @@+<?php++namespace App\Models;++use Illuminate\Database\Eloquent\Model;++class Storyboard extends Model {+ /**+ * id -> int8 (pk)+ * metadata_uuid -> int8 (fk) (unique) (index) (onDelete=cascade)+ *+ * tile_rows -> int2+ * tile_cols -> int2+ * tile_width -> int2+ * tile_height -> int2+ * tile_count -> int2+ *+ * interval_ms -> int4+ *+ * created_at -> timestamptz (nullable)+ * updated_at -> timestamptz (nullable)+ * modified_at -> timestamptz (nullable)+ */+ protected $casts = [+ 'modified_at' => 'datetime',+ ];+}diff --git a/database/migrations/2026_05_18_174157_create_images_table.php b/database/migrations/2026_05_18_174157_create_images_table.phpnew file mode 100644index 00000000..784153a4--- /dev/null+++ b/database/migrations/2026_05_18_174157_create_images_table.php@@ -0,0 +1,44 @@+<?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::create('images', function (Blueprint $table) {+ $table->id();+ $table->foreignUuid('metadata_uuid')->constrained('metadata', 'uuid')->cascadeOnDelete();++ $table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();++ $table->smallInteger('image_type');+ $table->smallInteger('image_source');+ $table->boolean('is_primary')->default(false);++ $table->integer('width')->nullable();+ $table->integer('height')->nullable();+ $table->string('blurhash', 64)->nullable();++ $table->text('path')->nullable();+ $table->text('source_url')->nullable();++ $table->timestampsTz();++ $table->index(['metadata_uuid', 'image_type']);+ });++ DB::statement('CREATE UNIQUE INDEX images_primary_unique ON images (metadata_uuid, image_type) WHERE is_primary = true');+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void {+ Schema::dropIfExists('images');+ }+};diff --git a/database/migrations/2026_05_18_174317_create_storyboards_table.php b/database/migrations/2026_05_18_174317_create_storyboards_table.phpnew file mode 100644index 00000000..02c29cf7--- /dev/null+++ b/database/migrations/2026_05_18_174317_create_storyboards_table.php@@ -0,0 +1,35 @@+<?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::create('storyboards', function (Blueprint $table) {+ $table->id();+ $table->foreignUuid('metadata_uuid')->constrained('metadata', 'uuid')->cascadeOnDelete()->unique();++ $table->smallInteger('tile_rows');+ $table->smallInteger('tile_cols');+ $table->smallInteger('tile_width');+ $table->smallInteger('tile_height');+ $table->smallInteger('tile_count');++ $table->integer('interval_ms');++ $table->timestampsTz();+ $table->timestampTz('modified_at');+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void {+ Schema::dropIfExists('storyboards');+ }+};