fix: remove old stale data
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-22 01:32:19 +02:00
parent cef6ee5820
commit 48ad82acd1
5 changed files with 69 additions and 60 deletions
+26 -7
View File
@@ -10,9 +10,15 @@ async function main() {
// Clean existing data so seed is idempotent
await prisma.auditLog.deleteMany();
await prisma.tabEvent.deleteMany();
await prisma.tabReminder.deleteMany();
await prisma.plannedTab.deleteMany();
await prisma.remoteCommand.deleteMany();
await prisma.openTabSnapshot.deleteMany();
await prisma.tabOwnership.deleteMany();
await prisma.settlement.deleteMany();
await prisma.tab.deleteMany();
await prisma.stockAdjustment.deleteMany();
await prisma.product.deleteMany();
await prisma.productImage.deleteMany();
await prisma.refreshToken.deleteMany();
await prisma.registrationCode.deleteMany();
await prisma.device.deleteMany();
@@ -83,11 +89,24 @@ async function main() {
];
for (const tab of tabsData) {
await prisma.tabOwnership.create({
data: { tabId: tab.tabId, venueId, deviceId, lastReportedAt: tab.reportedAt },
});
await prisma.openTabSnapshot.create({
data: { deviceId, tabId: tab.tabId, customerName: tab.customerName, version: tab.version, totalInCents: tab.totalInCents, itemCount: tab.itemCount, reportedAt: tab.reportedAt },
// One line with itemCount units, priced so the tab adds up to about totalInCents
const lineId = uuidv4();
const addedAt = tab.reportedAt.toISOString();
await prisma.tab.create({
data: {
venueId,
id: tab.tabId,
customerName: tab.customerName,
openedAt: tab.reportedAt,
version: tab.version,
lines: [{
id: lineId,
productId: null,
productName: 'Pils',
unitPriceInCents: Math.round(tab.totalInCents / tab.itemCount),
units: Array.from({ length: tab.itemCount }, (_, i) => ({ id: `${lineId}:${i}`, addedAt, removedAt: null })),
}],
},
});
}