c006 / yii2-migration-utility

Automatically writes the create tables for migrations or create tables in general. Uses MySQL
MIT License
64 stars 35 forks source link

Error if Default column value is CURRENT_TIMESTAMP #1

Closed Insolita closed 10 years ago

Insolita commented 10 years ago

(tested with mysql table only) For fix in AppUtility.php

private function runMySql()
        {
            if ( isset($this->array['dbType']) )
                $this->string .= $this->Tab . "'{$this->array['name']}' => '" . strtoupper($this->array['dbType']) . "";
            if ( isset($this->array['allowNull']) )
                $this->string .= ($this->array['allowNull']) ? ' NULL' : ' NOT NULL';
            if ( isset($this->array['autoIncrement']) )
                $this->string .= ($this->array['autoIncrement']) ? ' AUTO_INCREMENT' : '';
            if ( isset($this->array['defaultValue']) )
                if(!is_array($this->array['defaultValue'])){
                    $this->string .= (empty($this->array['defaultValue'])) ? '' : " DEFAULT \'{$this->array['defaultValue']}\'";
                }else{
                    $this->string .= (empty($this->array['defaultValue'])) ? '' : " DEFAULT ".$this->array['defaultValue']['expression']." ";
                }
        }
c006 commented 10 years ago

Thank you, updated.