migrate defaultExpression not support postgresql nextval()
What steps will reproduce the problem?
$this->alterColumn(
'{{%productdata}}',
'productdata_id',
$this->integer()->defaultExpression("nextval('epmms_productdata_productdata_id_seq')")->notNull()
);
What is the expected result?
alter column productdata_id in table {{%productdata}} to integer NOT NULL DEFAULT nextval('epmms_productdata_productdata_id_seq') ...Exception: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "(" LINE 1: ...ctdata" ALTER COLUMN "productdata_id" TYPE integer('epmms_pr... ^ The SQL being executed was: ALTER TABLE "epmms_productdata" ALTER COLUMN "productdata_id" TYPE integer('epmms_productdata_productdata_id_seq'), ALTER COLUMN "productdata_id" SET DEFAULT nextval, ALTER COLUMN "productdata_id" SET NOT NUL
What do you get instead?
$this->execute("alter table epmms_productdata alter column productdata_id set default nextval('epmms_productdata_productdata_id_seq')");
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.38 |
| PHP version | 8.0rc2 |
| Operating system | dcoker on windows |
I'm afraid that anything with brackets doesn't work in defaultExpression() or defaultValue().
I came across to this problem with defaultExpression('now()').
It somehow brokes the whole SQL query in a very strange way.