yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

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

Open buttflattery opened this issue 4 years ago • 1 comments

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

buttflattery avatar Mar 31 '21 11:03 buttflattery

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

samdark avatar Apr 02 '21 21:04 samdark