-
Notifications
You must be signed in to change notification settings - Fork 181
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
Incremental migration does not configure existing PK column to enable auto-generated values #381
Comments
To add to this, I forgot to mention that in order for the auto-generation to be configured for the PK column, I had to run:
After doing this, starting the app and creating a todo (without sending an {
"id": 1,
"title": "todo title",
"desc": "todo description",
"isComplete": false
} |
Thank you for reporting this issue, @aharbis. I think we need to improve I think we should detect the opposite transition too, from Would you like to contribute this fix yourself? |
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. |
Sorry for this going stale. I would be interested in submitting this patch. I will try to find some time to get this done. |
I've been tinkering with this, and I'm a little torn on how to handle this. Technically, moving from a property defined by: properties = {
example: {
type: Number
}
} to: properties = {
example: {
type: Number,
generated: true
}
} would yield a change in column type from I'm certainly fine if we want to keep this as a separate check, but it seems I'd likely need to leverage Side note, in my testing, it seems like What are your thoughts, @bajtos? |
For reference, the I've added a test case (that fails currently) to demonstrate this bug. Implementing the change should allow the test case to pass. |
Thinking a little more on this. The original issue I reported was focused on the behavior with the
So maybe I need to take a small step back and reassess how I'm approaching this issue. I was planning on simply looking for |
@aharbis I am afraid I am not able to help you much. By now, you know much more about this problem than I do 🤷♂
It is entirely possible that the fact that I think we should find out what design & behavior makes sense for majority of all connectors and then modify both juggler and the connectors to support that desired solution. |
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. |
#404 might be related to this issue |
I am also facing this issue. And my issue is resolved with a workaround "npm run migrate -- --rebuild" |
Description/Steps to reproduce
From my testing using LoopBack 4 and this connector, the migration performed by
npm run migrate
does not configure theid
(primary key) column to be auto-generated whengenerated: true
is enabled on the property.Link to reproduction sandbox
I've set up a branch on my
loopback-next
fork with a recreate. The branch is here:https://github.com/aharbis/loopback-next/tree/postgres-pk-auto-gen
The recreate uses the todo application. There are two commits on the branch:
aharbis/loopback-next@cdee3cb - Adds the Postgres data source
aharbis/loopback-next@43368cc - Sets
generated: true
on todo modelSteps to recreate
npm i
)npm run migrate
)npm start
)generated: true
)npm run migrate
)npm start
)Expected result
In step 10, this create should succeed and the ID should be auto-generated.
Actual result
In step 10, this create yields a 500 error:
Additional information
The text was updated successfully, but these errors were encountered: