Skip to content

When new required fields with a default value are added autoupdate shouldn't fail #123

Closed
@faridnsh

Description

@faridnsh

Steps to produce:

1 - Create a model and run autoupdate/automigrate
2 - Add a new required property with a default value to the model for example:

    "newProperty": {
      "type": "Number",
      "required": true,
      "default": 0
    }

3 - Run autoupdate again

What's expected: New column should be added with the default value.

What actually happens: Autoupdate fails here and throws this:

error: column "newProperty" contains null values

It happens because it tries to add column with NOT NULL constraint, but this is only possible, if we give a default value, but loopback-connector-postgresql ignores the given default value in the model configuration.

I would like to contribute this myself, but I'm not sure if I'm getting the test configuration to work. I'm getting error: password authentication failed for user "user" for the first test, but the credentials in the configuration are correct and also a lot of other tests are failing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions