Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Migration Generator: Default value for JSON column generates a migration for equal values #13

Closed
cebe opened this issue Aug 3, 2020 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@cebe
Copy link
Owner

cebe commented Aug 3, 2020

Schema in OpenAPI:

  customFields:
    type: array
    x-db-type: json
    default: '[]'
    items:
      type: object

generated migration:

class m200803_210001_change_table_projects extends \yii\db\Migration
{
    public function safeUp()
    {
        $this->alterColumn('{{%projects}}', 'customFields', "SET DEFAULT '[]'");
    }

    public function safeDown()
    {
        $this->alterColumn('{{%projects}}', 'customFields', "SET DEFAULT '[]'");
    }
}

There is no change in up and down.

This happens on PostgreSQL

@cebe cebe added the bug Something isn't working label Aug 3, 2020
@cebe cebe added this to the 2.0 milestone Aug 3, 2020
@cebe cebe closed this as completed Aug 10, 2020
cebe pushed a commit that referenced this issue Jan 27, 2023
…ral-expression-using-new-field-x-db-default-expression

Draft: Implement default by literal expression using new field 'x-db-default-expression'
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant