Hi,

I try to modify a MySQL DB column with the following : Phalcon\Db\Dialect\Mysql\modifyColumn and I always get this error :

SQLSTATE[22004]: Null value not allowed: 1138 Invalid use of NULL value

Here is my code :

private function getColumnFromDefinition(TableDefinition $tableDefinition) {

    $type = DatabaseType::getTypeByID($tableDefinition->ColumnType);

    $column = "";

    switch($type) {

        //String
        default: {

            $column = new PhalconColumn($tableDefinition->ColumnName, array(

              "type" => $type,
              "schemaName" => 'mySchema',
              "size" => $tableDefinition->ColumnSize,
              "notNull" => $tableDefinition->IsNotNull
            ));
        }
    }

    return $column;
}

$column = Phalcon\Db\Column object {
  _columnName => (string) Test
  _schemaName => null
  _type => (int) 2
  _isNumeric => (bool) false
  _size => (string) 50
  _scale => (int) 0
  _unsigned => (bool) false
  _notNull => (bool) true
  _primary => (bool) false
  _autoIncrement => (bool) false
  _first => (bool) false
  _after => null
  _bindType => (int) 2
}

$connection->modifyColumn($tableName, '', $column) 

This is the generated SQL by Phalcon :

ALTER TABLE `TableName` MODIFY `Test` VARCHAR(50) NOT NULL

Even in MySQL, it throw an error.

I found this explication here :

https://blog.mclaughlinsoftware.com/2011/03/26/adding-not-null-constraint/

"Change the column definition from null allowed to not null for the TESTING_TEXT column. The only problem with this syntax is that it only works when there are no null values in the table or there are no rows in the table."