Advertise with us

YII migrations and bu default values for table columns

Hi Everyone!

public function up(){

        $this->createTable('POST', array(
            'id' => 'pk',
            'isremoved' => 'integer NOT NULL',
            'removaldate' => 'timestamp NULL',
            'post' => 'text NOT NULL',
            'creationdate' => 'timestamp NOT NULL',
        ));
}

This is the up function for migration. As u see it is query for creating new table. By default YII creates default value for timestamp column equal to CURRENT_TIMESTAMP and crates additional parameter and sets it equal to ON UPDATE CURRENT_TIMESTAMP.

I do not need current value for timestamp and I do not need to update this column on updating row. What i must to do? By the way, u use MySQL

Thanks in advance! 

Last updated:5/15/2013 8:56:14 AM

1 Answers

AVADHESH PATEL
AVADHESH PATEL

Hi Royce!


You have to set other default value, null for example

public function up(){
        $this->createTable('POST', array(
            'id' => 'pk',
            'isremoved' => 'integer NOT NULL',
            'removaldate' => 'timestamp DEFAULT NULL',
            'post' => 'text NOT NULL',
            'creationdate' => 'timestamp DEFAULT NULL',
        ));
}

I hope it help to you.

Answer