-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Bug report
Required System information
- Node.js version: 14.18.2
- NPM version: 6.14.15
- Strapi version: 4.1.7
- Database: PostgreSQL
- Operating system: Ubuntu
Describe the bug
I have a Strapi version 3.6.9 project and have created a new Strapi project using 4.1.7 with the same collection-types and components. On this occasion, I decided not to migrate and to re-create manually as part of an exercise.
I am experiencing a create index already exists error when creating a one-to-one relational field on a component.
"reference_cell": {
"type": "relation",
"relation": "oneToOne",
"target": "api::reference-cell.reference-cell"
}
On doing so, I get the following error:
[
{
sql: 'create table "public"."components_readings_information_tp_informations_reference_cell_links" ("tp_information_id" integer null, "reference_cell_id" integer null)',
bindings: []
},
{
sql: 'create index "components_readings_information_tp_informations_reference_cell_links_fk" on "public"."components_readings_information_tp_informations_reference_cell_links" ("tp_information_id")',
bindings: []
},
{
sql: 'create index "components_readings_information_tp_informations_reference_cell_links_inv_fk" on "public"."components_readings_information_tp_informations_reference_cell_links" ("reference_cell_id")',
bindings: []
}
]
[2022-03-20 11:20:08.690] debug: ⛔️ Server wasn't able to start properly.
[2022-03-20 11:20:08.692] error: create index "components_readings_information_tp_informations_reference_cell_links_fk" on "public"."components_readings_information_tp_informations_reference_cell_links" ("tp_information_id") - relation "components_readings_information_tp_informations_reference_cell_" already exists
error: create index "components_readings_information_tp_informations_reference_cell_links_fk" on "public"."components_readings_information_tp_informations_reference_cell_links" ("tp_information_id") - relation "components_readings_information_tp_informations_reference_cell_" already exists
Please note that I have a one-to-one relational field on another component for a different collection-type of which is fault-type of which there is no error.
I have tried creating new databases with and without this field. Application runs fine without this additional field. Only seems to occur with this.
Steps to reproduce the behavior
- Create one-to-one relational field on component
- See create index ... already exists error
Expected behavior
Should be able to create one-to-one relational field on component like have done
with other component.
Screenshots
Code snippets
"reference_cell": {
"type": "relation",
"relation": "oneToOne",
"target": "api::reference-cell.reference-cell"
}
{
"kind": "collectionType",
"collectionName": "fault_types",
"info": {
"singularName": "fault-type",
"pluralName": "fault-types",
"displayName": "fault type"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"description": {
"type": "text"
}
}
}
{
"collectionName": "components_readings_information_faults",
"info": {
"displayName": "fault",
"icon": "angle-down",
"description": ""
},
"options": {},
"attributes": {
"fault_desc": {
"type": "text"
},
"fault_type": {
"type": "relation",
"relation": "oneToOne",
"target": "api::fault-type.fault-type"
}
}
}
Note that no errors occur when adding fault-type relational field to faults component.
Additional context
Sorry if this isn't a bug but I have tried many attempts to understand otherwise why this is occurring. I have also raised a question at https://forum.strapi.io/t/create-index-already-exists/16835


