-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigation breaks with Strapi export/import #317
Comments
Per a recommendation from Strapi: |
Hello @unsalted , Strapi is right here, we've got custom relations made to handle entities properly in multiple navigations. Let me dig into the import - export functionality of Strapi and see how we can fix this issue on our end. |
@unsalted I've did couple of tests and seems the issue been found. I’ve checked in deep and exported data are correct, as well the imported relations & links are proper except one thing. After import the What I did is the import on a same database without cleaning up any indexing so counting is continued on every table. That many imports I did it always increase the With a fresh database import works perfectly. I've notified Strapi about that case, because seems it's a non handled corner case for import / export. Please try to import on the clear database schema and you'll see it works. |
@cyp3rius do you think it's due to the sequence not being restarted on the target table before we reimport the data? |
Might be. I've reproduced the same thing couple of times with exact same result. |
Odd that the actual data tables work but the relational joining tables don't. When testing with normal content-types and relations I'm not able to reproduce the issue 🤔 |
DEITS is designed to map the entries for the new IDs automatically and handle the linking |
Indeed, I've tested with relations done from the UI interface and typical content types - works. Possibly, but I'm not sure - the plugin content types and relations are injected to DB earlier than the content type from Content Manager and are not re-iterated once ID change. Clear & new DB - No issues, as re-iteration is not necessary. |
I haven't looked at the code for this plugin in a -really- long time, let me see how you are are injecting them. |
I'm guessing that's designed for custom polymorphic relationships? |
I think the case is with the @derrickmehaffy any idea how to provide custom import logic for plugin and update those fields properly, when content type id changes? |
Ah yeah I see: strapi-plugin-navigation/server/content-types/navigations-items-related/schema.ts Lines 25 to 46 in bdda349
These aren't setup as real relations so the relation handler isn't treating them as such, they are just |
I'm not sure, I'll need to talk to our DX Squad about it. |
Some kind of:
Or similar, whats going to allow such entities been updated. |
The way DEITS handles links is defined in here: https://github.com/strapi/strapi/blob/main/packages/core/data-transfer/src/strapi/queries/link.ts |
The issue I'm guessing is we are directly looking for relation types and since those fields are just strings nothing is done to them |
Thanks for jumping on this issue so quickly. I appreciate it. |
@derrickmehaffy I've checked the transfer package and indeed as for now there is no possibility for us to "run" custom logic after import and get those changes applied. Do you think the DX team might consider some kind of routines for plugin creators like |
Probably not in the short term, we could in the future possibly but it'll be a while before they will have time to implement something. |
Any movement on this? We may need to drop the plugin and implement a custom solution because it has become a blocker on several initiatives. @derrickmehaffy it sounds like there isn't an existing hook for afterImport, has there been any movement on implementing one? |
Hello @unsalted, |
For the moment no we won't have the time for the next few months to add something like this to DTS. |
I don't believe polymorphic relations should be used here and probably should be using oneWay relationships. I don't have a full understanding of how that is stored in the plugin though. |
Navigation Items got relations to unspecified content types so if relations, then only poly might be used as I understand that correctly. OneWay relations must have specified target which represent the Collection / Single Type. As we've been using pyli in a past but it wasn't perfect and need a lot of control. |
Correct me if I am wrong: The problem lies in referencing related content in menu items via ids, which are resolved manually, instead of by explicit relations which would automatically be handled by strapi, as pointed out above by @derrickmehaffy. If I remember correctly, such a situation in other ORM-Systems is modeled via something called "polymorphic relations". |
As a practical intermediate solution one might consider a feature that enables referencing related user defined content via some other unique field other than it's ID... |
Yes we do have polymorphic relationships but generally advise against them due to their complexity. For example the media field is actually a polymorphic relationship. Polymorphic relationships I don't believe are documented but it is possible. |
I simply made a new navigation plugin that supports strapi import/export, since I don't see much progress in solving major issues such as emport/export. It's quite stable, but the feature set might differ. Happy to take feature requests and pull requests. Any feedback is most welcome. Pros:
Another alternative is: |
I understand that one solution to this problem is to "clear database schema" and import again. How exactly do i clear a database schema? Is there a CLI command or should I just delete the DB file (I use SQLite)? |
This will be somewhat solved in Strapi v5 as we are moving to string-based CUIDs instead (basically short form UUIDs) as primary keys instead of integers. |
We do a semi regular export from our production environment, and then import in our staging environment with the new Strapi import/export feature.
The navigation structure copies, but the content-type and menu relations are missing.
The impact is we can't use our staging environment for testing because navigation is broken.
strapi-plugin-navigation: 2.4
strapi: 4.8
The text was updated successfully, but these errors were encountered: