Skip to content

Seed simple data into the database (useful for setting permissions and settings)

Notifications You must be signed in to change notification settings

ChappIO/directus-extension-seed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Directus CLI Extension: Seed

Note: This extension is very much under development. Use at own risk.

Seed your directus instance from .yml files from the CLI.

Usage:

  1. Install the extension: npm install directus-extension-seed.
  2. Create your seed file: 00_directus_settings.yml:
    # This key is the collection to import into
    directus_settings:
     # directus_settings is a singleton collection so its id is always 1
      - id: 1
        project_name: My Backoffice
        project_url: https://thing.com
        project_color: #7B219F
  3. Run directus data apply ./path/to/your/file.yml

Essentially, the .yml file contains your collection data which should be upserted. Note that primary keys are required as they are used to determine if the image should be updated or added.

Dumping data

  1. Install the extension: npm install directus-extension-seed.
  2. Run directus data snapshot --output <targetFile> <collections...> (For example: directus data snapshot --output dump.yml directus_settings)

Some Examples:

To grant public read access to the projects collection:

directus_permissions:
   - id: 1
     collection: projects
     role: null
     action: read
     fields: "*"

To create a role with full rights on the projects collection:

directus_roles:
   - id: 8a4cabd2-53d9-4be4-9d23-5d27b459ef7f
     name: Project Manager
        
directus_permissions:
   - id: 2
     role: 8a4cabd2-53d9-4be4-9d23-5d27b459ef7f
     collection: projects
     action: create
     fields: "*"
   - id: 3
     role: 8a4cabd2-53d9-4be4-9d23-5d27b459ef7f
     collection: projects
     action: read
     fields: "*"
   - id: 4
     role: 8a4cabd2-53d9-4be4-9d23-5d27b459ef7f
     collection: projects
     action: update
     fields: "*"
   - id: 5
     role: 8a4cabd2-53d9-4be4-9d23-5d27b459ef7f
     collection: projects
     action: delete
     fields: "*"

About

Seed simple data into the database (useful for setting permissions and settings)

Resources

Stars

Watchers

Forks

Packages

No packages published