rezo-labs / directus-extension-schema-management-module Goto Github PK
View Code? Open in Web Editor NEWUI to easily share schema/role between Directus apps
License: GNU General Public License v3.0
UI to easily share schema/role between Directus apps
License: GNU General Public License v3.0
For example, I added one field to directus_users, need a way to export the changes and import it into another directus instance.
for my directus docker instance (10.6.1), i had to install using the following:
yarn add argon2 2> /dev/null
yarn add directus-extension-schema-management-module
reboot
Unfortunately it needs argon2, I don't know why. And furthermore, it errors out while installing argon2 hence the redirected errors. This is more of an afterthought but wondering if there's a way to shed light on this.
Using Directus 9.21.* When exporting the schema of a collection, the schema value is empty, which seems to cause relationships to fail. When I add the name of the collection to the schema value in the JSON, I can apply the schema without errors.
Example Exported Collection
"collections": [ { "collection": "test_collection_2", "meta": { "collection": "test_collection_2", "icon": null, "note": null, "display_template": null, "hidden": false, "singleton": false, "translations": null, "archive_field": "status", "archive_app_filter": true, "archive_value": "archived", "unarchive_value": "draft", "sort_field": null, "accountability": "all", "color": null, "item_duplication_fields": null, "sort": 68, "group": null, "collapse": "open" }, "schema": {} } removed fields and relations ]
When I use the above with npx directus schema apply ./file.json
I get the following error:
ERROR: Failed to create relation "test_collection_2.image"
ERROR: Invalid payload. Collection "test_collection_2" doesn't exist.
err: {
"type": "",
"message": "Invalid payload. Collection \"test_collection_2\" doesn't exist.",
"stack":
DirectusError: Invalid payload. Collection "test_collection_2" doesn't exist.
at RelationsService.createOne (file:///directus/node_modules/.pnpm/file+api/node_modules/@directus/api/dist/services/relations.js:119:19)
at file:///directus/node_modules/.pnpm/file+api/node_modules/@directus/api/dist/utils/apply-diff.js:206:44
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
"name": "DirectusError",
"extensions": {
"reason": "Collection \"test_collection_2\" doesn't exist"
},
"code": "INVALID_PAYLOAD",
"status": 400
}
After changing schema to be:
"schema": {"name": "test_collection_2"}
The apply works.
Maybe this is more of a Directus issue with the data coming out of the API? Thank you for considering this.
To make this package complete, it would be really helpful to include roles and permissions in the export / import.
I know this technically is not schema, but is a key component for a full dev / prod sync.
Great job on supporting also roles and permissions. am only missing public role import/export ?
When importing a schema file, I can choose between two strategies:
Instead when importing roles that exist already, an error is thrown:
Maybe the same resolution logic that is used for choosing to skip existing collections or to identify the patch can also be offered for role imports?
When i exporting my scheme from ui. i can't select "folder" collection.
when i importing my schema from another instance. i got following error:
Invalid foreign key for field "group" in collection "directus_collections" when importing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.