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

Migration Generator: Default value for integer should not be considered string #11

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

Comments

@cebe
Copy link
Owner

cebe commented Aug 3, 2020

Having the following OpenAPI schema:

  flags:
    type: integer
    default: 0

and a column in the database: flags INT DEFAULT 0

The following migration is generated:

/**
 * Table for User
 */
class m200803_210000_change_table_users extends \yii\db\Migration
{
    public function safeUp()
    {
        $this->alterColumn('{{%users}}', 'flags', "SET DEFAULT 0");
    }

    public function safeDown()
    {
        $this->alterColumn('{{%users}}', 'flags', "SET DEFAULT '0'");
    }
}

Changing yaml to:

  flags:
    type: integer
    default: "0"

making the 0 a string value does not generate a migration.

This happens on Postgres.

@cebe cebe added the bug Something isn't working label Aug 3, 2020
@Insolita
Copy link
Collaborator

need additional check

@cebe
Copy link
Owner Author

cebe commented Aug 16, 2020

need additional check

what do you mean? Is this solved or still something left to do?

@Insolita
Copy link
Collaborator

Yes, it solved now

@cebe cebe closed this as completed Aug 17, 2020
@cebe cebe added this to the 2.0 milestone Aug 17, 2020
cebe pushed a commit that referenced this issue Jan 19, 2023
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

2 participants