eZ Platform Discussions

[Kaliop Migrations Bundle] Create content if not already exist

version2

#1

Bonjour,

Is it possible with the Kaliop Migrations Bundle to create a content if it does not already exist?

-
    type: content
    mode: load
    match:
        location_remote_id: initial_import
    references:
        -
            identifier: initial_import_already_exist
            attribute: count

-
    type: reference
    mode: dump
    identifier: reference:initial_import_already_exist

-
    mode: create
    type: content
    content_type: folder
    parent_location: 2
    location_remote_id: initial_import
    attributes:
        name: initial_import
    if:
        "reference:initial_import_already_exist":
            ne: 1

At the first execution it creates well the folder.

But if I run it again:

Migration aborted! Reason: Error in execution of step 3: Argument ‘$locationCreateStructs’ is invalid: Another Location with remoteId ‘initial_import’ exists

The problem comes from the creation of the reference because the debug indicates 0 and if I force it to 1 it is good.

-
    type: reference
    mode: set
    identifier: initial_import_already_exist 
    value: 1 
    overwrite: true 

Merci pour votre aide.


#2

Hi @janit .

You seem to be an expert on the Kaliop Migrations Bundle. Maybe you have an idea for my pb?

Thanks :slight_smile: