Migrator Methods

The Migrator class from the VARIO App Framework provides methods for setting up your app's infrastructure during installation. This reference covers all methods relevant to shop and marketplace integrations.

Creating a Migrator

const { Migrator } = require('@vario-software/vario-app-framework-backend/utils/migrator');

const migrator = new Migrator('migration-key');

The migration-key is a unique identifier for this set of migrations. It's used to track which migrations have already been executed.

Core Methods

setMigration(key, callback)

Executes a migration function once. The framework tracks the execution using the key. On subsequent installations or updates, the migration is skipped.

await migrator.setMigration('create-sales-channel', async (methods) =>
{
  // This code runs only once
  const backend = await methods.createSalesChannelBackend('My Shop', ['ECOMMERCE']);
});

Parameters:

Parameter
Type
Description

key

string

Unique migration identifier

callback

function

Async function receiving a methods object

always(key, callback)

Executes a function every time the migration runs (on every install/update). Use this for things that should always be up to date, like app scripts or webhook URLs.

Sales Channel Methods

createSalesChannelBackend(label, validChannelTypes)

Creates a sales channel backend for your app. There should be exactly one backend per app.

Returns: Backend object with id and other properties.

createSalesChannel(backend, label, description, channelType)

Creates a sales channel under a backend.

Returns: Sales channel object.

activateSalesChannelBackend(backend)

Activates a sales channel backend, enabling its channels.

changeSalesChannelBackend(body)

Updates an existing sales channel backend.

findSalesChannelBackend()

Finds the APP-type sales channel backend for the current app.

Returns: Backend object or null.

getSalesChannels()

Returns all sales channels for the current app.

Returns: Array of sales channel objects.

getSalesChannelBackend(id)

Returns a specific sales channel backend by ID.

EAV Methods

createEavGroup(key, data, description)

Creates an EAV group for storing custom data.

getEavGroup(key)

Retrieves an EAV group by key.

changeEavGroup(key, callback)

Modifies an EAV group using a callback pattern:

deleteEavGroup(key)

Deletes an EAV group and all its data.

removeDataFromEavGroup(key, attributes)

Removes specific attributes from an EAV group without deleting the group.

Webhook Methods

registerWebhook(destinationQueue, url, destinationOwner)

Registers a webhook to receive ERP event notifications.

With custom destination owner:

deregisterWebhook(destinationQueue, url, destinationOwner)

Removes a previously registered webhook.

Import Preset Methods

createMultipartImportPreset(template)

Creates an import preset for the MultiPart Import API.

updateMultipartImportPreset(id, template)

Updates an existing import preset.

Text Enum Methods

createTextEnumGroup(key, description, enums)

Creates a group of text enumerations (dropdown options):

App Scripting Methods

addAppScriptingTrigger(trigger)

Registers a server-side script trigger in the ERP.

updateAppScriptingTrigger(id, trigger)

Updates an existing scripting trigger.

getAppScriptingTriggerId(code)

Gets the ID of a scripting trigger by its code.

Finance Backend Methods

createFinanceBackend(label)

Creates a finance backend for payment processing.

changeFinanceBackend(label, description)

Updates a finance backend.

Usage Example: Complete Shop Installation

Was this helpful?