Skip to content

Commit 6b62f14

Browse files
committed
Default value for json columns
1 parent fc39131 commit 6b62f14

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

database/migrations/create_places_table.php.stub

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Query\Expression;
45
use Illuminate\Database\Schema\Blueprint;
56
use Illuminate\Support\Facades\Schema;
67

@@ -20,11 +21,11 @@ class CreatePlacesTable extends Migration
2021
$table->foreignId('image_id')->nullable();
2122
$table->string('latitude', 30)->nullable();
2223
$table->string('longitude', 30)->nullable();
23-
$table->json('status');
24-
$table->json('title');
25-
$table->json('slug');
26-
$table->json('summary');
27-
$table->json('body');
24+
$table->json('status')->default(new Expression('(JSON_OBJECT())'));
25+
$table->json('title')->default(new Expression('(JSON_OBJECT())'));
26+
$table->json('slug')->default(new Expression('(JSON_OBJECT())'));
27+
$table->json('summary')->default(new Expression('(JSON_OBJECT())'));
28+
$table->json('body')->default(new Expression('(JSON_OBJECT())'));
2829
$table->timestamps();
2930
});
3031
}

0 commit comments

Comments
 (0)