Skip to content

A self-hosted media server and file management system

fix: subtitle uuid should be null on delete and be cleaned manually later

aminnausin08bed1110058
diff --git a/database/migrations/2026_01_17_005022_change_metadata_uuid_fk_on_subtitles.php b/database/migrations/2026_01_17_005022_change_metadata_uuid_fk_on_subtitles.php
new file mode 100644
index 00000000..420d4a9f
--- /dev/null
+++ b/database/migrations/2026_01_17_005022_change_metadata_uuid_fk_on_subtitles.php
@@ -0,0 +1,37 @@
+<?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::table('subtitles', function (Blueprint $table) {
+ $table->dropForeign(['metadata_uuid']);
+
+ $table->uuid('metadata_uuid')->nullable()->change();
+ $table->foreign('metadata_uuid')
+ ->references('uuid')
+ ->on('metadata')
+ ->nullOnDelete();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('subtitles', function (Blueprint $table) {
+ $table->dropForeign(['metadata_uuid']);
+
+ $table->uuid('metadata_uuid')->nullable(false)->change();
+ $table->foreign('metadata_uuid')
+ ->references('uuid')
+ ->on('metadata')
+ ->cascadeOnDelete();
+ });
+ }
+};