From 74e42d5fb4f0c5b46f91ef5934d9e601016d05b3 Mon Sep 17 00:00:00 2001 From: AmirmahdiNourkazemi Date: Sun, 24 May 2026 23:25:36 +0330 Subject: [PATCH] fix --- ..._175608_change_duration_to_integer_in_music_table.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/database/migrations/2026_05_22_175608_change_duration_to_integer_in_music_table.php b/database/migrations/2026_05_22_175608_change_duration_to_integer_in_music_table.php index 89c1f06..d6ebc11 100644 --- a/database/migrations/2026_05_22_175608_change_duration_to_integer_in_music_table.php +++ b/database/migrations/2026_05_22_175608_change_duration_to_integer_in_music_table.php @@ -11,6 +11,10 @@ */ public function up(): void { + // For PostgreSQL, we need to use a raw statement with USING clause + DB::statement('ALTER TABLE music ALTER COLUMN duration TYPE integer USING (duration::integer)'); + + // Then make it nullable if needed Schema::table('music', function (Blueprint $table) { $table->integer('duration')->nullable()->change(); }); @@ -21,8 +25,11 @@ public function up(): void */ public function down(): void { + // Convert back to string/text + DB::statement('ALTER TABLE music ALTER COLUMN duration TYPE text USING (duration::text)'); + Schema::table('music', function (Blueprint $table) { $table->string('duration')->nullable()->change(); }); } -}; +}; \ No newline at end of file