How to Duplicate a Collection

What is the best approach to duplicating an entire Collection? I would like to take the Posts and Workflow that is in the Demo project and duplicate it, so all the fields transfer over to the new Collection. I don’t necessarily need the posts to be duplicated, although that would be okay too.

3 Answers

3

Hi @oneeleven :wave: welcome to the community! Glad to have you.

Could you expand on your use case a bit? That would help me point you in a better direction. There might be a simpler approach depending on what you’re actually trying to accomplish.

To answer the question in the meantime -

Unfortunately, Directus doesn’t have a built-in way to duplicate a collection with all its fields and relationships in one click. We do have the ability to copy non relational fields from one collection to another, but I get that’s not quite the same.

If you just need to duplicate a single collection in one project, it might be easier just to quickly do via the UI, our in-app AI assistant, or using the Directus MCP with your preferred AI tools.

If you truly need to a way to repeatable way to duplicate collections what you can do today is use the Directus API and write a script that handles the duplication for you. At a high level, you’d need to:

  1. Create the new collection
  2. Create the corresponding fields in that collection
  3. Establish any relationships

I don’t have a tutorial specifically for this since duplicating an entire collection is not a super common request. Normally I’d just use the existing collection and add a field that I could filter by to get the different types of records I require.


On the 1. Workflow view from your screenshot, that’s just a bookmark of the Post collection using a different layout. It’s powered by Directus Presets under the hood. Same data, just a different way to look at it. :+1:

The Demo project has meta data and the workflow associated with it. When I create a new Collection, it obviously doesn’t have any of that. It would be nice if I could find a quick way to create a bunch of identical Collections based off of the Posts in the Demo.

Workflow in the Demo project.