EventConfig: Use text column instead of json if not supported
This commit is contained in:
parent
7f61dc95be
commit
689ad7d5d5
|
@ -5,6 +5,7 @@ namespace Engelsystem\Migrations;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Engelsystem\Database\Migration\Migration;
|
use Engelsystem\Database\Migration\Migration;
|
||||||
use Engelsystem\Models\EventConfig;
|
use Engelsystem\Models\EventConfig;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
class CreateEventConfigTable extends Migration
|
class CreateEventConfigTable extends Migration
|
||||||
|
@ -21,11 +22,23 @@ class CreateEventConfigTable extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->schema->create('event_config', function (Blueprint $table) {
|
foreach (['json', 'text'] as $type) {
|
||||||
$table->string('name')->index()->unique();
|
try {
|
||||||
$table->json('value');
|
$this->schema->create('event_config', function (Blueprint $table) use ($type) {
|
||||||
$table->timestamps();
|
$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')) {
|
if ($this->schema->hasTable('EventConfig')) {
|
||||||
$config = $this->schema->getConnection()
|
$config = $this->schema->getConnection()
|
||||||
|
|
Loading…
Reference in New Issue