yii2
yii2 copied to clipboard
Altering a timestamp field to remove CURRENT_TIMESTAMP and On Update CURRENT_TIMESTAMP attributes
What steps will reproduce the problem?
create a field via migration for the start with defaultExpression() as CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP

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 |
Seems to be tricky to properly fix it. There are database-specific differences.