Skip to content

Commit

Permalink
Default value for json columns + use of constrained() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sdebacker committed May 27, 2022
1 parent 9b47c98 commit 912d6cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 9 additions & 8 deletions database/migrations/create_events_table.php.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Expand All @@ -17,14 +18,14 @@ class CreateEventsTable extends Migration
$table->date('end_date');
$table->boolean('registration_form');
$table->foreignId('image_id')->nullable();
$table->json('status');
$table->json('title');
$table->json('slug');
$table->json('venue');
$table->json('address');
$table->json('summary');
$table->json('body');
$table->json('website');
$table->json('status')->default(new Expression('(JSON_OBJECT())'));
$table->json('title')->default(new Expression('(JSON_OBJECT())'));
$table->json('slug')->default(new Expression('(JSON_OBJECT())'));
$table->json('venue')->default(new Expression('(JSON_OBJECT())'));
$table->json('address')->default(new Expression('(JSON_OBJECT())'));
$table->json('summary')->default(new Expression('(JSON_OBJECT())'));
$table->json('body')->default(new Expression('(JSON_OBJECT())'));
$table->json('website')->default(new Expression('(JSON_OBJECT())'));
$table->timestamps();
});
}
Expand Down
3 changes: 1 addition & 2 deletions database/migrations/create_registrations_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateRegistrationsTable extends Migration
{
Schema::create('registrations', function (Blueprint $table) {
$table->id();
$table->foreignId('event_id');
$table->foreignId('event_id')->constrained();
$table->foreignId('user_id')->nullable();
$table->unsignedInteger('number_of_people');
$table->string('email')->nullable();
Expand All @@ -22,7 +22,6 @@ class CreateRegistrationsTable extends Migration
$table->string('locale')->nullable();
$table->text('message')->nullable();
$table->timestamps();
$table->foreign('event_id')->references('id')->on('events');
});
}

Expand Down

0 comments on commit 912d6cd

Please sign in to comment.