bcc-code / directus-schema-sync

The better way to sync your Directus schema and data between environments
Apache License 2.0
110 stars 4 forks source link

Role sync? #37

Closed NilsBaumgartner1994 closed 4 months ago

NilsBaumgartner1994 commented 5 months ago

Describe the Improvement

Is it possible to sync the roles? As I found there is a way to synchronize permissons.

martin-braun commented 4 months ago

Sure there is. Have you inspected the configuration carefully?

It's part of the default configuration in directus_config.js:

export const syncDirectusCollections = {
  directus_roles: {
    watch: ["roles"],
  },
  directus_permissions: {
    watch: ["permissions", "collections", "fields"],
    excludeFields: ["id"],
    getKey: (o) => `${o.role ?? "public"}-${o.collection}--${o.action}`,
    query: {
      sort: ["role", "collection", "action"],
    },
  },
}
u12206050 commented 4 months ago

Correct.

as a side-note: The getKey is more of a suggestion than a must have, ie. if you need the same role id across environments, and you also sync a few admin users for example then you would want the role id to be synced as well so you would then remove the getKey

martin-braun commented 4 months ago

@u12206050 Glad that you've answered me on this one, would've fall into that pitfall in the future. Since I only init with admin users I guess it wasn't a problem.