From 689ad7d5d598fd83ab467662cba2a6f5c7a48859 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 3 Oct 2018 18:47:25 +0200 Subject: EventConfig: Use text column instead of json if not supported --- ...2018_09_24_000000_create_event_config_table.php | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'db') diff --git a/db/migrations/2018_09_24_000000_create_event_config_table.php b/db/migrations/2018_09_24_000000_create_event_config_table.php index 18298100..dd457d3f 100644 --- a/db/migrations/2018_09_24_000000_create_event_config_table.php +++ b/db/migrations/2018_09_24_000000_create_event_config_table.php @@ -5,6 +5,7 @@ namespace Engelsystem\Migrations; use Carbon\Carbon; use Engelsystem\Database\Migration\Migration; use Engelsystem\Models\EventConfig; +use Illuminate\Database\QueryException; use Illuminate\Database\Schema\Blueprint; class CreateEventConfigTable extends Migration @@ -21,11 +22,23 @@ class CreateEventConfigTable extends Migration */ public function up() { - $this->schema->create('event_config', function (Blueprint $table) { - $table->string('name')->index()->unique(); - $table->json('value'); - $table->timestamps(); - }); + foreach (['json', 'text'] as $type) { + try { + $this->schema->create('event_config', function (Blueprint $table) use ($type) { + $table->string('name')->index()->unique(); + $table->{$type}('value'); + $table->timestamps(); + }); + } catch (QueryException $e) { + if ($type != 'json') { + throw $e; + } + + continue; + } + + break; + } if ($this->schema->hasTable('EventConfig')) { $config = $this->schema->getConnection() -- cgit v1.2.3-54-g00ecf