strapi / migration-scripts

Collection of Strapi Migration scripts
58 stars 58 forks source link

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

Open lrasata opened 1 year ago

lrasata commented 1 year ago

Bug report

Required System information

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

dadugawde2001 commented 1 month ago

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