Skip to content

--merge option deletes all remote items in synced collection during import #54

@cyprian-nziim

Description

@cyprian-nziim

Describe the Bug

I was able to create a CICD flow to update my local schema an data to my remote instance when I push to my repo, however each time I modify the local data in a specific collection, all data in my remote instance is reset to my local instance data state deleting all the other items in the collection in my remote instance.

To Reproduce

I have a local directus instance (Installed Via NPM) and PostgreSQL. I do all my local work with this instance when I want to deploy I have the following file in my repo.

My Dockerfile

FROM directus/directus:11.2.1

USER root
RUN corepack enable

// Workaround to be able to install extensions with 'node' user, only required in v11.1.1
RUN rm node_modules/.modules.yaml

RUN pnpm install [email protected]


WORKDIR /directus

COPY ./schema-sync ./schema-sync

My docker-compose file

version: "8"
services:
  directus-app:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: directus-app:1.0.6
    volumes:
      - ./schema-sync:/directus/schema-sync
      - ./extensions:/directus/extensions
    command: >
      sh -c "
        npx directus schema-sync import --merge
      "

Directus Version

v11.2.1

Hosting Strategy

Self-Hosted (Docker Image)

Database

PostgreSQL

  1. Export local DB with "npx directus schema-sync export"
  2. Perform an initial Commit and Push to repo
  3. CICD builds the image and pushes to server, on startup runs "npx directus schema-sync import --merge" app is deployed all is good
  4. Add a new item in remote instance to a collection you have marked for sync in "directus-app/schema-sync/directus_config.js"
  5. Update or Add an Item in any collection via the directus interphase on the local instance, make sure its in a collection you have marked for sync in "directus-app/schema-sync/directus_config.js"
  6. Run "npx directus schema-sync export" on local instance to sync changes
  7. Commit and push to repo
  8. CICD builds the image and pushes to server, on startup runs "npx directus schema-sync import --merge" this deletes all items in collection in remote instance and resets collection to local state

Version

3.0.2

Installed Extension Via

Docker file

Metadata

Metadata

Assignees

No one assigned

    Labels

    incidentSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions