59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import prisma from '../src/lib/prisma';
|
|
import crypto from 'crypto';
|
|
|
|
async function main() {
|
|
const menu = await prisma.menu.findUnique({
|
|
where: { name: 'main' }
|
|
});
|
|
|
|
if (!menu || !menu.payload) {
|
|
console.error('Menu main not found or payload is empty');
|
|
return;
|
|
}
|
|
|
|
const payload = menu.payload as any[];
|
|
let updated = false;
|
|
|
|
for (let i = 0; i < payload.length; i++) {
|
|
const node = payload[i];
|
|
if (node.nodeId === 'b4b2faf8-8881-4ca9-a8d5-a88054a37385') {
|
|
if (node.links && !node.columns) {
|
|
console.log('Fixing Scent Guide node...');
|
|
|
|
const newColumn = {
|
|
nodeId: crypto.randomUUID(),
|
|
title: {
|
|
en: 'Essential Oils',
|
|
th: 'น้ำมันหอมระเหย',
|
|
ja: 'エッセンシャルオイル',
|
|
ko: '에센셜 오일',
|
|
vi: 'Tinh dầu',
|
|
zh: '精油'
|
|
},
|
|
links: node.links
|
|
};
|
|
|
|
node.columns = [newColumn];
|
|
delete node.links;
|
|
updated = true;
|
|
} else {
|
|
console.log('Scent Guide node already has columns or no links to fix.');
|
|
}
|
|
}
|
|
}
|
|
|
|
if (updated) {
|
|
await prisma.menu.update({
|
|
where: { name: 'main' },
|
|
data: { payload }
|
|
});
|
|
console.log('Successfully updated main menu payload.');
|
|
} else {
|
|
console.log('No updates were necessary.');
|
|
}
|
|
}
|
|
|
|
main()
|
|
.catch(console.error)
|
|
.finally(() => prisma.$disconnect());
|