This commit is contained in:
Your Name committed 2026-06-15 21:04:50 -04:00
1 parent 9370869dc2
commit b8873f88b0
4 files changed
+351 -3

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
import prisma from '../src/lib/prisma';
function fixNode(node: any) {
if (node.translations) {
const labelKey = node.title !== undefined ? 'title' : 'label';
if (typeof node[labelKey] === 'string') {
node[labelKey] = { en: node[labelKey] };
}
node[labelKey] = { ...(node[labelKey] || {}), ...node.translations };
delete node.translations;
}
if (node.columns && Array.isArray(node.columns)) {
node.columns.forEach((col: any) => fixNode(col));
}
if (node.links && Array.isArray(node.links)) {
node.links.forEach((link: any) => fixNode(link));
}
if (node.items && Array.isArray(node.items)) {
node.items.forEach((item: any) => fixNode(item));
}
}
async function main() {
const menu = await prisma.menu.findUnique({
where: { name: 'main' }
});
if (!menu || !menu.payload) {
console.log('No main menu payload found');
return;
}
const payload = menu.payload as any[];
console.log('Original payload length:', payload.length);
payload.forEach(fixNode);
await prisma.menu.update({
where: { name: 'main' },
data: { payload }
});
console.log('Menu fixed successfully');
}
main()
.catch(e => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
+58
View File
@@ -0,0 +1,58 @@
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());