Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Some fields of some Content-types are displayed twice in Content Manager after running Migration-scripts #88

Open
lrasata opened this issue Feb 7, 2023 · 4 comments

Comments

@lrasata
Copy link

lrasata commented Feb 7, 2023

Bug report

Required System information

  • Node.js version: v14.19.3
  • NPM version: v6.14.17
  • Source Strapi version: v3.6.6
  • Target Strapi version: v4.5.6
  • Source Database: Postgres
  • Target Database: Postgres
  • Operating system: macOS
  • Which script are you running: v3-sql-v4-sql

Describe the bug

After running migration-scripts, when consulting the details of one entry, some fields appears twice.
Below for example for the Content-type : News-type, the field : 'type' appears twice
Screenshot 2023-02-08 at 9 27 31 AM

When the schema.json of News-type is :

  "kind": "collectionType",
  "collectionName": "news_types",
  "info": {
    "singularName": "news-type",
    "pluralName": "news-types",
    "displayName": "News-type",
    "name": "news-type"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "pluginOptions": {
    "i18n": {
      "localized": true
    }
  },
  "attributes": {
    "type": {
      "type": "string",
      "required": true,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    }
  }
}

I also checked the database and there is no double column 'type'. So it is just a problem in the view. See below, we have the Config view edit and the field 'type' appears twice for some reason.
Screenshot 2023-02-08 at 9 31 17 AM

Interestingly the 2 other Content-types which are linked to News-type have some problem in their view as well :
Latest-news-and-resource

{
  "kind": "collectionType",
  "collectionName": "news_and_resources",
  "info": {
    "singularName": "latest-news-and-resource",
    "pluralName": "latest-news-and-resources",
    "displayName": "Latest-news-and-resource",
    "name": "latest-news-and-resource",
    "description": ""
  },
  ...
  "attributes": {
    "title": {
      "type": "string",
      "required": true,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    },
    ...
    "news_type": {
      "type": "relation",
      "relation": "oneToOne",
      "target": "api::news-type.news-type"
    },
    "primary_category": {
      "type": "relation",
      "relation": "manyToOne",
      "target": "api::category.category",
      "inversedBy": "primary_category_news_and_resources"
    },
    "other_categories": {
      "type": "relation",
      "relation": "manyToMany",
      "target": "api::category.category",
      "inversedBy": "other_categories_news_and_resources"
    },
    ...
    }
  }
}

For Latest-news-and-resources, the fields : news-type, primary_category, other_categories . All appear twice as in the image below :
Screenshot 2023-02-08 at 9 32 27 AM

And it is the same for Category :

{
  "kind": "collectionType",
  "collectionName": "categories",
  "info": {
    "singularName": "category",
    "pluralName": "categories",
    "displayName": "Category",
    "name": "category"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "pluginOptions": {
    "i18n": {
      "localized": true
    }
  },
  "attributes": {
    "name": {
      "type": "string",
      "required": true,
      "pluginOptions": {
        "i18n": {
          "localized": true
        }
      }
    },
    "primary_category_news_and_resources": {
      "type": "relation",
      "relation": "oneToMany",
      "target": "api::latest-news-and-resource.latest-news-and-resource",
      "mappedBy": "primary_category"
    },
    "other_categories_news_and_resources": {
      "type": "relation",
      "relation": "manyToMany",
      "target": "api::latest-news-and-resource.latest-news-and-resource",
      "mappedBy": "other_categories"
    }
  }
}

Screenshot 2023-02-08 at 9 37 33 AM

It looks like this problem only appear for Content-types which have '-' hyphen in the name and is linked to other Content-types.
Once again the database and the model files are all fine, it is just in the view.

Steps to reproduce the behavior

  1. Run migration-scripts : v3-sql-v4-sql with some Collection-types with '-' in the name and link them to Content-type with a relation
  2. All data are fully migrated
  3. Go to 'Content-Manager' of view the detail of one entry
  4. See that some fields are displayed twice

Expected behavior

No fields should be displayed twice.

Additional context

The duplicated field through the Config view edit of the Content Manager. But we would like to avoid any manual action because we aren't necessarily aware where this may appear and we aren't sure if it will appear again.

@romeomihalovics
Copy link

romeomihalovics commented Mar 27, 2023

The type column is filtered out in the migrateCoreStore.js file, from the metadatas when the valueToSave variable is set. After the migration you wont see the problem, but after the first start of strapi, it will generate the missing metadata for your column, and adds an extra entry for the layouts prop as well in the db [inside the strapi_core_store_settings table]

you'll have to remove the type col from the omitted keys when you need to generate metadata for it to avoid duplicating fields after strapi starts.

@elliotlaws
Copy link

@romeomihalovics I'm also seeing this issue, can you explain more verbosely what needs to be done here?

Are you suggesting that we update the migrateCoreStore file?

@satiye
Copy link

satiye commented Sep 15, 2023

@romeomihalovics can you please give more details about your suggestion?

@dadugawde2001
Copy link

I am also facing the same issue can anyone please provide a solution to this problem .
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants