Skip to content

[v4] When create a "Has one" relation on collection, it creates a mapping table #11695

@ghost

Description

Bug report

Describe the bug

A problem occured when creating a "Has one" relation between collections.
Assume there are "employee" and "company" collections. Then "employees" and "companies" tables exist in the database.
I created a "Has one" relation between "employee" and "company" collections on Strapi CMS.
In v3, "company_id" column is created in "employees" table. But, in v4, creates the mapping table "employees_company_id_links".
I'm not sure if this is an intended feature or a bug, so I'm creating this issue.

Steps to reproduce the behavior

  1. Create "employee" and "company" collections.
  2. Create a "employee has one Company" relation in the "employee" collection.
  3. Check the database table.

Expected behavior

A "company_id" column is added as a foreign key to the "employees" table.

Screenshots

[Strapi v3]
v3-11
v3-22
v3-33

[Strapi v4]
v4-11
v4-22
v4-33
v4-44

Code snippets

https://github.com/lejinseop/strapi-v4-database-relation-test

System

  • Node.js version: 14.15.5
  • NPM version: 8.1.4
  • Strapi version: 4.0.0-beta.17
  • Database: Postgres 13.4
  • Operating system: MAC OS (PostgresDB in docker container)

Additional context

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions