From 9f4e6a5376a5aa16762ba41fb1934e258df83e24 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 3 Nov 2021 12:31:42 +0100 Subject: [PATCH] wip #4857 @0.5 --- src/app/Console/Commands/MigrateCommand.php | 6 +++++- src/app/Magic/Fields/Field.php | 7 ++++--- src/app/Magic/Fields/LongText.php | 8 ++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/app/Magic/Fields/LongText.php diff --git a/src/app/Console/Commands/MigrateCommand.php b/src/app/Console/Commands/MigrateCommand.php index 52d4dac..e802117 100644 --- a/src/app/Console/Commands/MigrateCommand.php +++ b/src/app/Console/Commands/MigrateCommand.php @@ -59,7 +59,11 @@ class MigrateCommand extends CubistMagicCommand $queries = $diff->toSaveSql($connection->getDatabasePlatform()); foreach ($queries as $q) { - $connection->exec($q); + try { + $connection->exec($q); + } catch (\Exception $e) { + throw new \Exception('Error executing query ' . $q . ' : ' . $e->getMessage()); + } } } diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index 148ab56..8eacc21 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -140,7 +140,7 @@ class Field implements \ArrayAccess 'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable, 'preview' => $this->_preview, 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'column_width' => 300, - 'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic, + 'default' => null, 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic, 'allow_null' => true, 'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth, 'database_type' => $this->_databaseType, 'database_unique' => $this->_databaseUnique, 'database_index' => $this->_databaseIndex, 'database_default' => $this->_databaseDefault, @@ -296,8 +296,9 @@ class Field implements \ArrayAccess $this->_databaseAttributes ); - if ($this->getAttribute('database_default') !== null) { - $attributes['default'] = $this->getAttribute('database_default'); + $default = $this->getAttribute('database_default') ?? $this->getAttribute('default'); + if ($default !== null) { + $attributes['default']=$default; } $table->addColumn($name, diff --git a/src/app/Magic/Fields/LongText.php b/src/app/Magic/Fields/LongText.php new file mode 100644 index 0000000..2de301e --- /dev/null +++ b/src/app/Magic/Fields/LongText.php @@ -0,0 +1,8 @@ +