Skip to content

Commit 886427e

Browse files
authored
The default blueprint in core has changed, so update seeder to replicate (#170)
1 parent 8499f7f commit 886427e

File tree

3 files changed

+39
-18
lines changed

3 files changed

+39
-18
lines changed

database/migrations/create_blueprints_table.php.stub

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ return new class extends Migration {
3939
],
4040
'handle' => 'content',
4141
],
42-
[
43-
'field' => [
44-
'type' => 'users',
45-
'display' => 'Author',
46-
'default' => 'current',
47-
'localizable' => true,
48-
'max_items' => 1,
49-
],
50-
'handle' => 'author',
51-
],
52-
[
53-
'field' => [
54-
'type' => 'template',
55-
'display' => 'Template',
56-
'localizable' => true,
57-
],
58-
'handle' => 'template',
59-
],
6042
],
6143
]);
6244
} catch (\JsonException $e) {

src/ServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ServiceProvider extends AddonServiceProvider
4242
protected $updateScripts = [
4343
\Statamic\Eloquent\Updates\AddOrderToEntriesTable::class,
4444
\Statamic\Eloquent\Updates\AddBlueprintToEntriesTable::class,
45+
\Statamic\Eloquent\Updates\ChangeDefaultBlueprint::class,
4546
\Statamic\Eloquent\Updates\DropForeignKeysOnEntriesAndForms::class,
4647
];
4748

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Statamic\Eloquent\Updates;
4+
5+
use Statamic\Eloquent\Fields\BlueprintModel;
6+
use Statamic\UpdateScripts\UpdateScript;
7+
8+
class ChangeDefaultBlueprint extends UpdateScript
9+
{
10+
public function shouldUpdate($newVersion, $oldVersion)
11+
{
12+
return $this->isUpdatingTo('2.3.0');
13+
}
14+
15+
public function update()
16+
{
17+
$model = BlueprintModel::where('handle', 'default')->first();
18+
19+
if ($model) {
20+
$model->data = [
21+
'fields' => [
22+
[
23+
'field' => [
24+
'type' => 'markdown',
25+
'display' => 'Content',
26+
'localizable' => true,
27+
],
28+
'handle' => 'content',
29+
],
30+
],
31+
];
32+
33+
$model->save();
34+
35+
$this->console()->info('Successfully updated the default blueprint');
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)