Skip to content

A self-hosted media server and file management system

fix: migrations for date_uploaded loses data

aminnausin7933dbf5fd02
diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.php
index d9d3212a..95cd502d 100755
--- a/app/Jobs/VerifyFiles.php
+++ b/app/Jobs/VerifyFiles.php
@@ -222,7 +222,7 @@ class VerifyFiles extends ManagedSubTask {
if (! is_null($scannedDirectories[$folderPath]['external_subtitles'])) {
$relevantSubtitles = array_filter(
$scannedDirectories[$folderPath]['external_subtitles'],
- fn($sub) => strtolower($sub['media_filename']) === strtolower($fileName)
+ fn ($sub) => strtolower($sub['media_filename']) === strtolower($fileName)
);
$externalSubtitleTransactions = $subtitleScanner->buildSubtitleTransactions(
diff --git a/database/migrations/2026_01_28_015136_add_scanned_at_to_metadata.php b/database/migrations/2026_01_28_015136_add_scanned_at_to_metadata.php
index b3534f79..3a92979e 100644
--- a/database/migrations/2026_01_28_015136_add_scanned_at_to_metadata.php
+++ b/database/migrations/2026_01_28_015136_add_scanned_at_to_metadata.php
@@ -14,7 +14,7 @@ return new class extends Migration {
$table->timestampTz('file_scanned_at')->nullable();
});
- DB::table('metadata')->whereNotNull('date_scanned')->update(['file_scanned_at' => DB::raw('date_scanned')]);
+ DB::table('metadata')->whereNotNull('date_scanned')->update(['file_scanned_at' => DB::raw('date_scanned')]); // No timestamp available because date_scanned was just a date field
}
/**
diff --git a/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php b/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php
index a8ae2e69..e5bc9726 100644
--- a/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php
+++ b/database/migrations/2026_01_28_173810_add_file_modified_at_to_metadata.php
@@ -11,7 +11,7 @@ return new class extends Migration {
*/
public function up(): void {
Schema::table('metadata', function (Blueprint $table) {
- $table->timestampTz('file_modified_at')->nullable(); // TODO: eventually make this nullable when enforced by api (currently you can initiate a metadata when you edit a media item that has not been verified)
+ $table->timestampTz('file_modified_at')->nullable(); // TODO: eventually make this not nullable when enforced by api (currently you can initiate a metadata when you edit a media item that has not been verified)
});
DB::table('metadata')->whereNotNull('date_uploaded')->update(['file_modified_at' => DB::raw("date_uploaded AT TIME ZONE 'UTC'")]);
diff --git a/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php b/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php
index 266359dc..1b6708c7 100644
--- a/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php
+++ b/database/migrations/2026_01_30_051158_remove_date_uploaded_from_metadata.php
@@ -11,7 +11,7 @@ return new class extends Migration {
*/
public function up(): void {
Schema::table('metadata', function (Blueprint $table) {
- $table->dropColumn("date_uploaded");
+ $table->dropColumn('date_uploaded');
});
}
@@ -20,9 +20,9 @@ return new class extends Migration {
*/
public function down(): void {
Schema::table('metadata', function (Blueprint $table) {
- $table->date("date_uploaded")->nullable();
+ $table->timestamp('date_uploaded')->nullable();
});
- DB::table('metadata')->whereNotNull('file_modified_at')->update(['date_uploaded' => DB::raw('DATE(file_modified_at)')]);
+ DB::table('metadata')->whereNotNull('file_modified_at')->update(['date_uploaded' => DB::raw("file_modified_at AT TIME ZONE 'UTC'")]);
}
};