-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When new required fields with a default value are added autoupdate shouldn't fail #123
Comments
@raymondfeng @superkhau @bajtos : I would like to address this issue, but I'm unable to run the test right now. I saw on the Readme that I need to contact you for instructions so I do. |
@Elindorath You have two ways to configure your postgres connection.
Or drop
Please also use https://github.com/strongloop/loopback-connector-postgresql/blob/master/test/tables.sql to populate your test db. |
Thanks @raymondfeng. I'll try to give you an update this week-end. |
@Elindorath Any update on this issue? It seems that the connector is trying to add the column and set the The way I worked around it was to drop the |
If a model property has a default value, set that as the database column's default value when adding the column in an auto update. This ensures that existing database rows will have a value for the new column, and prevents the autoupdate failing due to null values. Fixes loopbackio#123
If a model property has a default value, set that as the database column's default value when adding the column in an auto update. This ensures that existing database rows will have a value for the new column, and prevents the autoupdate failing due to null values. Fixes loopbackio#123
This is a mergeable update to loopbackio#153 that also respects dbDefault.
This is a mergeable update to loopbackio#153 that also respects dbDefault.
This is a mergeable update to loopbackio#153 that also respects dbDefault.
This is a mergeable update to loopbackio#153 that also respects dbDefault.
This is a mergeable update to loopbackio#153 that also respects dbDefault.
* Add connectorCapabilities global object (#179) (Nicholas Duffy) * Accept PGDATABASE env var in test/init.js (#178) (Simon Ho) * Remove unused prefix from test env vars (#176) (Simon Ho) * Fix #123: Set default value during autoupdate. (#167) (Samuel Reed) * Update translation files - round#2 (#170) (Candy) * Add translated files (gunjpan) * Update deps to loopback 3.0.0 RC (Miroslav Bajtoš) * Use juggler@3 for running tests (Candy) * Add eslint infrastructure (Loay) * Revert "Add eslint infrastructure" (Loay) * Fix CI Failure (Loay) * test: accept more env vars on CI (Ryan Graham) * test: use 'emptytest' database as default (Ryan Graham) * test: seed DB with test schema before running (Ryan Graham) * test: separate dbconfig from datasource (Ryan Graham) * test: replace tables.sql with full schema dump (Ryan Graham) * Refactor (jannyHou) * Upgrade version (jannyHou) * Globalize discover.js (jannyHou) * Update URLs in CONTRIBUTING.md (#150) (Ryan Graham)
Is this fixed? |
To me this seems to be still a bug, either defaultFn or default is not honerred during migrations and it will fail. |
I'm still running into this issue today |
I ran into this today as well, the manual workaround is dangerous in the long term |
same, looks like code isn't merged to master yet. |
I'm running into this today, and it's breaking our production deploy. |
Ended up running manual ALTER statements. 👎 |
@raymondfeng @bajtos need your help here how to resolve this issue?is this fix part of the connector or we need to do this patch on the existing library to bypass the main issue? |
Still running into the issue today. |
For those who end up here and are wondering about the status of the issue, there's similar issue reported which is open as of this moment. here is the link. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Need to open this again. This is still an issue in 2024. |
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:
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:
It happens because it tries to add column with
NOT NULL
constraint, but this is only possible, if we give a default value, butloopback-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.The text was updated successfully, but these errors were encountered: