fix migration for mairet dev

This commit is contained in:
Jérémy Munsch 2023-02-02 14:34:31 +01:00
parent 74f88ffc0e
commit 2ebcf417c0
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -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');
});