Foreign key update causes loading errors

Feature(s) impacted

Unable to load certain pages on ForestAdmin

Observed behavior

When a foreign key is added, I’m unable to load the data anymore.

Expected behavior

I expect the panel to work properly.

Failure Logs

Pop up saying “Fetch record failed: Your data seems to be invalid: Expected 1 values, found 2”

How to Reproduce / Recent Changes

Before

  • table A - cols (id, x, y, xy)
    • pkey (x, y)
    • unique constraint (xy)
  • table B - cols (id, xy)
    • fkey to table A on col xy

Then, I deleted table A pkey, table A unique key, and table B fkey on table A and re-added table A pkey. (no problems loading here) and re-added table B fkey on table A (at this point I start getting problems).

After

  • table A - cols (id, x, y, xy)
    • pkey (xy)
  • table B - cols (id, xy)
    • fkey to table A on col xy

Context

  • Project name: PM for details
  • Team name: PM for details
  • Environment name: PM for details
  • Database type: PostGres
  • Recent changes made on your end if any: see above

And, if you are self-hosting your agent:

  • not self-hosting

Hi @cmeng ,

Can you share the network call that leads to the error ?

In the new structure of the DB, is there still the unique contraint on “xy” ?

The error seems to indicate that somehow, forest or your DB still have references to the 2 deleted columns (“found 2”). If it’s not your DB, “sync database schema” in forest should solve the issue. It should be done everytime you change something in the DB structure.

Cheers,

Enki

Hi Enki,

Can you share the network call that leads to the error ?

I get it when I try to access a specific record in table A and the fkey link when I check table B seems to be missing (makes me think of Missing related data ) it’s the same tables as before.

In the new structure of the DB, there is just the primary key on “xy” (which verifies uniqueness).

There were no columns deleted on our end, just the change in the foreign key. I can assure you I re-sync the database when I change the DB, and often when I try to troubleshoot errors like this.

Cheers,

@cmeng

Ok, give me the names of the collections in private, so I can check the database introspection