Automatically-generated schema shows many-to-many instead of one-to-many relationships

Feature(s) impacted

Schema generation

Observed behavior

I have three tables patients, medicines and medicine_treatments in my DB schema, where the medicine_treatment contains two foreign keys patientId and medicineCisCode to the two other tables.

I use Forest Admin with NestJS, with the automatic DB schema discovery and generation. My problem is that Forest Admin (or rather Liana, if I understood correctly) understands the relationship between patients and medicine_treatments as being a many-to-many: thus, it shows the medicines linked to my patient (through medicine_treatments); however, my medicine_treatments table contains more information than just the two foreign keys, and I would like to see this info. In short, I would like to have a normal one-to-many relationship between patients and medicine_treatments (and also between medicines and medicine_treatments), instead of this many-to-many relationship.


Is there any way I can “customize” the schema generation to force one-to-many relationships creation instead of many-to-many ones?

Expected behavior

One-to-many relationship between the tables.


  • Project name: Nov-1
  • Team name: Novesia
  • Environment name: All
  • Agent (forest package) name & version: forest-nodejs-agent v.1.13.3
  • Database type: PostgreSQL

You can create the relation with the following code, and just hide the other one with removeField or simply hide it from the frontend.

agent.customizeCollection('patients', collection => {
  collection.addOneToManyRelationship('treatments', 'medicine_treatments', { originKey: 'patientId' });
1 Like