Skip to content
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

Relations error when created without directus in version 3 #127

Open
Khartir opened this issue Dec 17, 2024 · 1 comment
Open

Relations error when created without directus in version 3 #127

Khartir opened this issue Dec 17, 2024 · 1 comment
Labels
directus-related This issue is related to Directus itself

Comments

@Khartir
Copy link
Contributor

Khartir commented Dec 17, 2024

Describe the bug
I'm currently in the progress of upgrading to directus 11 and directus-sync 3. In our setup we use directus on top of an existing database, so directus is not primarily responsible for creating the schema, but we run directus-sync with the schema anyway to ensure we don't accidentally configure some schema changes. So far this has worked great.
But there is a problem since the upgrade: In the CI directus is started on an empty database, then an external script runs to add the schema and then directus-sync runs.
In this situation we now get an error Failed to create relation "x.y". The table x is not configured in directus at all. Until the upgrade this worked fine.

To Reproduce
Steps to reproduce the behavior:

  1. Create a schema with relations which are not configured in directus.
  2. Run npx directus-sync pull.
  3. The relations are part of the dump.
  4. Create a completely new database.
  5. Start directus with this new database.
  6. Import the schema without directus-sync.
  7. Run npx directus-sync push.

Expected behavior
No errors. With directus-sync 2.2/directus 10 this worked fine.

Versions (please complete the following information):

  • Directus-Sync version: [3.1.6]
  • Directus version: [11.3.3]
  • Directus environment [Docker]

Additional context
The issue does not occur locally, where usually directus is started after the schema was created. I assume this is an issue with some missing caching or parsing that occurs in directus on startup.
I assume this issue could be fixed by restarting the directus container after schema creation but that is unfortunately not possible in the CI.
If this is not something you feel should be fixed, I would appreciate it if you could tell me if there is an endpoint or sdk-call we could make that has the same effect. (Assuming this is something you removed because it is generally not necessary).

@EdouardDem
Copy link
Member

@Khartir I think this issue is related to Directus directly. Directus-Sync manage the schema by using the schema snapshot endpoints.
Maybe you need to clear the system cache after changing the database : https://docs.directus.io/reference/system/utilities.html#clear-the-internal-cache

@EdouardDem EdouardDem added the directus-related This issue is related to Directus itself label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
directus-related This issue is related to Directus itself
Projects
None yet
Development

No branches or pull requests

2 participants