can't select the table id I always select the table id field as a foreign key but today I found that the reference was broken, and the id can't be selected, it not appear as an option
I'd suggest PGAdmin also, but if you're not a DB person and figuring out a whole new IDE sounds like overkill for this you could create a new Query and use the Retool Database resource type, then switch to SQL Mode and add:
BEGIN;
ALTER TABLE table_name
DROP CONSTRAINT constraint_fkey;
ALTER TABLE child_table
ADD CONSTRAINT constraint_name
FOREIGN KEY (fk_columns)
REFERENCES parent_table(parent_key_columns);
// you can also use the bellow line, just be sure to delete the semicolon above this line
// ON DELETE CASCADE;
COMMIT;
Then you can hit 'run' on the query and after it finishes running you can delete this Query, which I probably would incase someone would accidently run it or links it to a button or something.... I mean, obv unless you want to keep it to reuse for whatever reason
Yes, this is the issue, to set the primary key of the related table as a foreign key But directly in the DB as I used to
This is very important, to be able to set the foreign keys directly !!!
Thanks
Yup, I can confirm the same thing happened to me just now. Trying to set a foreign key won't identify a table's primary key if it is set up as UUID (which seems to be column type "Custom" ?)
ya just follow the Workaround For An Existing Column section. the sql code is the same, you just have to be sure the column types of both tables is the same
Also experiencing this same problem. The work around mentioned above adds just enough complexity across an already complex product I'm trying to build that it's not worth implementing in my case. Unfortunately I'll just have to wait till the fix is shipped.
I can confirm we're dealing with this same issues. It was very confusing and ultimately frustrating as selecting a table's auto-incrementing ID seems like such an obvious candidate as a foreign key. Tracking this issue for resolution...
Same issue with fkey, unable to select the primary key (or any field) of related table. Does not show as an option. Our workaround has been utilizing pgAdmin to create the relationships needed, but would be great to have a resolution on this retool bug.
When I view this connection in resources Retool databases I see the problem above. The ID-field flashes as selected, but I cannot select it anymore.
I tried to follow the workarounds, but I failed to make any change. Could somebody provide more detailed steps to fix this table situation? Current tables work, but when I try to create a new Foreign key field I see the same problem.
I have PGAdmin 4 access, but I have never used it before.
Maybe you could try to follow this video it shows how to create a foreign key on PgAdmin 4 with the User Interface without any SQL.
You would need to do it for your order_rows table.