From 2ebcf417c0413fedfa5cc9cc341441521baf8f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 2 Feb 2023 14:34:31 +0100 Subject: [PATCH] fix migration for mairet dev --- .../migrations/2022_10_03_111950_change_contents_table.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/database/migrations/2022_10_03_111950_change_contents_table.php b/database/migrations/2022_10_03_111950_change_contents_table.php index f4e4318..b69d9f2 100644 --- a/database/migrations/2022_10_03_111950_change_contents_table.php +++ b/database/migrations/2022_10_03_111950_change_contents_table.php @@ -50,6 +50,13 @@ class ChangeContentsTable extends Migration $page->slug = Str::slug($page->title ?? $page->value); $page->saveQuietly(); }); + $pages = StaticPage::all(); + $pages->each(function (StaticPage $page) use ($pages) { + if ($pages->where('slug', $page->slug)->count() > 1) { + $page->slug = "{$page->slug}2"; + } + $page->saveQuietly(); + }); Schema::table('static_pages', function (Blueprint $table) { $table->unique('slug'); });