diff --git a/application/Espo/Core/Utils/Database/Converters/Schema.php b/application/Espo/Core/Utils/Database/Converters/Schema.php index a6425f9381..aae693cfb1 100644 --- a/application/Espo/Core/Utils/Database/Converters/Schema.php +++ b/application/Espo/Core/Utils/Database/Converters/Schema.php @@ -18,6 +18,7 @@ class Schema 'default' => 'default', 'notnull' => 'notnull', 'autoincrement' => 'autoincrement', + 'unique' => 'unique', ); diff --git a/application/Espo/Resources/metadata/fields/autoincrement.json b/application/Espo/Resources/metadata/fields/autoincrement.json index a9e95aefea..3147548af4 100644 --- a/application/Espo/Resources/metadata/fields/autoincrement.json +++ b/application/Espo/Resources/metadata/fields/autoincrement.json @@ -7,6 +7,7 @@ }, "database":{ "type":"int", - "autoincrement":true + "autoincrement":true, + "unique":true } } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 73e5e691ea..a9e774c597 100644 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -541,6 +541,7 @@ class MySqlPlatform extends AbstractPlatform $column = $columnDiff->column; $columnArray = $column->toArray(); $columnArray['comment'] = $this->getColumnComment($column); + $queryParts[] = 'CHANGE ' . ($columnDiff->oldColumnName) . ' ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnArray); } diff --git a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php index c086c86a1e..e4467a680b 100644 --- a/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php +++ b/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php @@ -76,6 +76,11 @@ class Column extends AbstractAsset */ protected $_autoincrement = false; + /** + * @var boolean + */ + protected $_unique = false; //espo + /** * @var array */ @@ -222,6 +227,18 @@ class Column extends AbstractAsset return $this; } + /** + * @param boolean $unique + * + * @return \Doctrine\DBAL\Schema\Column + */ + public function setUnique($unique) //espo + { + $this->_unique = (bool)$unique; + + return $this; + } + /** * @param mixed $default * @@ -487,6 +504,7 @@ class Column extends AbstractAsset 'fixed' => $this->_fixed, 'unsigned' => $this->_unsigned, 'autoincrement' => $this->_autoincrement, + 'unique' => $this->_unique, //espo 'columnDefinition' => $this->_columnDefinition, 'comment' => $this->_comment, ), $this->_platformOptions, $this->_customSchemaOptions);