Shopify Metaobject and Metafield definitions require you to specify a strict schema of definitions and if (when) you need to change
those entities - you will need to do it via migrations.
Tento has a CLI tool for managing Shopify Metaobjects and Metafields schema definitions.
Based on your schema, Tento letβs you push your definitions schema directly to the Shopify, pull schema definitions from Shopify and has a couple of commands.
lets you push your Tento definitions schema directly to Shopify, see here
tento.config.ts
Tento migrations is configured through tento.config.ts configuration file.
Itβs required to provide schemaPath, shop and X-Shopify-Access-Token for Tento.
βββββββββββββββββββββββ β ~ tento push β βββ¬ββββββββββββββββββββ β ββββββββββββββββββββββββββββ β Pull current definitions schema ---------> β β β β β Generate alternations based on diff <---- β Shopify β β β β β Apply differences to the Shopify -------> β β β ββββββββββββββββββββββββββββ β ββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββ create metafield description, create metaobject designer;
Client
Tento also supports apply and removeschema definitions using client.
option
default
values
description
unknownEntities
ignore
ignore, remove
helps define the scope of metaobjects and metafields to be migrated, preventing unnecessary downloads and avoiding the deletion of other existing items
Apply
Remove
import 'dotenv/config';import '@shopify/shopify-api/adapters/web-api';import * as schema from './db/schema';import { createClient, tento } from '@drizzle-team/tento';const client = tento({ client: createClient({ shop: process.env.SHOPIFY_SHOP_ID!, headers: { "X-Shopify-Access-Token": process.env.SHOPIFY_ACCESS_TOKEN!, }, }), schema,});async function main() { // 'ignore' strategy as default await client.applySchema(); // you can specify explicitly configuration option you want await client.applySchema({ unknownEntities: "ignore" }); await client.applySchema({ unknownEntities: "delete" });}main();
import 'dotenv/config';import '@shopify/shopify-api/adapters/web-api';import * as schema from './db/schema';import { createClient, tento } from '@drizzle-team/tento';const client = tento({ client: createClient({ shop: process.env.SHOPIFY_SHOP_ID!, headers: { "X-Shopify-Access-Token": process.env.SHOPIFY_ACCESS_TOKEN!, }, }), schema,});async function main() { // 'ignore' strategy as default await client.removeSchema(); // you can specify explicitly configuration option you want await client.removeSchema({ unknownEntities: "ignore" }); await client.removeSchema({ unknownEntities: "delete" });}main();
ignore
means that only the metaobjects and metafields from your definitions schema will be processed.
delete
means that all metaobjects and metafields will be processed. If you select this option and run command, we will create/ update your schema in Shopify and remove all metaobjects and metafields that do not exist in your schema.