Go Migrations - Unable to create relation between users collection and X collection #3290
Replies: 3 comments 2 replies
-
|
I've just tested it locally with v0.18.3 and it works fine for me. What version of PocketBase do you use? Could you paste your current collections configuration as JSON (you can export it from the Admin UI > Settings > Export collections)? Is it possible that you've executed the migration with incorrect |
Beta Was this translation helpful? Give feedback.
-
|
Hi there, thank you for the reply :) I was running V0.18 , however upgrading to V0.18.3 seems to have fixed the issue, not sure why though I guess we can consider this resolved :D Thank you for your reply and help. |
Beta Was this translation helpful? Give feedback.
-
|
You're specifying the collection name rather than the collection id. If you want migrations to work, you need to specify a collection Id (you can do this by declaring a BaseCollection with the ID) in the referred collection and use that id in the referring fields relation options. This flow is a bit sticky right now, as setting collection ids in a go migration is not very intuitive. The generated migrations sidestep the issue by parsing JSON, which works but doesn't give great hints. I find myself translating JSON collections to Go when working with go migrations Id love to hear @ganigeorgiev's thoughts on how we handle go migrations. EDIT: I missed that you had already tried to get the id from the name. Never mind... |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I'm having some trouble creating a relationship between the default users table and a table I'd like to create using Go.
The problem seems to be related to the Id of the users table, however I'm not sure how to fix this issue; I have attempted both to use the 'pb_users_auth' string, as I saw that being used in the JS migrations, and I have also attempted :
and then
CollectionId: userCollection.Idhowever this approach failed as well. Below is my current migration file:Any help is greatly appreciated; I can confirm the migration is being run as I can see the new collection in the GUI, however the relation doesn't see the users table:
Beta Was this translation helpful? Give feedback.
All reactions