]> _ Git - cubist_cms-back.git/commitdiff
wip #4857 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Nov 2021 11:31:42 +0000 (12:31 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Nov 2021 11:31:42 +0000 (12:31 +0100)
src/app/Console/Commands/MigrateCommand.php
src/app/Magic/Fields/Field.php
src/app/Magic/Fields/LongText.php [new file with mode: 0644]

index 52d4dac94b3e63dcb8f894a25a8119c78791b360..e802117293ec38dfd70c5a70c13e8574c6b4b255 100644 (file)
@@ -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());
+                }
             }
         }
 
index 148ab5666ad57197019802e45fb1afe113417ca5..8eacc2174b3d7e1cdc97a48254106cce341cc976 100644 (file)
@@ -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 (file)
index 0000000..2de301e
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+namespace Cubist\Backpack\Magic\Fields;
+
+class LongText extends Text
+{
+    protected $_databaseType = 'text';
+}