Skip to content

A self-hosted media server and file management system

feat: add first file modified date to metadata

aminnausin9c9ffcca4293
diff --git a/app/Models/Metadata.php b/app/Models/Metadata.php
index f0b6085e..24f94d1f 100644
--- a/app/Models/Metadata.php
+++ b/app/Models/Metadata.php
@@ -53,7 +53,12 @@ class Metadata extends Model {
* edited_at -> timestamptz (nullable)
* file_scanned_at -> timestamptz (nullable)
*
- * file_modified_at -> timestamptz (nullable)
+ * file_modified_at -> timestamptz (nullable)
+ *
+ * intro_start -> float(2) (nullable)
+ * intro_duration -> float(2) (nullable)
+ *
+ * first_file_modified_at -> timestamptz (nullable)
*/
protected $fillable = [
// Id
@@ -94,6 +99,7 @@ class Metadata extends Model {
// Date Id
'file_scanned_at',
'file_modified_at',
+ 'first_file_modified_at',
'edited_at',
];
@@ -102,6 +108,7 @@ class Metadata extends Model {
protected $casts = [
'file_scanned_at' => 'datetime',
'file_modified_at' => 'datetime',
+ 'first_file_modified_at' => 'datetime',
'edited_at' => 'datetime',
'media_type' => MediaType::class,
diff --git a/database/migrations/2026_02_25_043102_add_first_file_date_to_metadata.php b/database/migrations/2026_02_25_043102_add_first_file_date_to_metadata.php
new file mode 100644
index 00000000..d1b471de
--- /dev/null
+++ b/database/migrations/2026_02_25_043102_add_first_file_date_to_metadata.php
@@ -0,0 +1,28 @@
+<?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('metadata', function (Blueprint $table) {
+ $table->timestampTz('first_file_modified_at')->nullable();
+ });
+
+ DB::table('metadata')->whereNull('first_file_modified_at')->whereNotNull('file_modified_at')->update(['first_file_modified_at' => DB::raw('file_modified_at')]);
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('metadata', function (Blueprint $table) {
+ $table->dropColumn('first_file_modified_at');
+ });
+ }
+};