yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Altering a timestamp field to remove CURRENT_TIMESTAMP and On Update CURRENT_TIMESTAMP attributes #18586

Open buttflattery opened 3 years ago

buttflattery commented 3 years ago

What steps will reproduce the problem?

create a field via migration for the start with defaultExpression() as CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP image

Then try to alter the column to remove the default current_timestamp and the on update current_timestamp using

$this->alterColumn($this->_table, 'start', $this->timestamp()->notNull());

What is the expected result?

I expect the column to drop the default and extra attributes for the field but it does not either if i use

$this->alterColumn($this->_table, 'start', $this->timestamp()->append('')->notNull());

Additional info

Q A
Yii version 2.0.41.1.
PHP version PHP 7.3.27-9+ubuntu20.04.1+deb.sury.org+1
Operating system Ubuntu
samdark commented 3 years ago

Seems to be tricky to properly fix it. There are database-specific differences.