Files
api/prisma/backfill-app-version.js
T
MahdiandCursor a6b3457779 Add production-ready SuperAdmin API features for tenants, SMS, servers, and plugins.
Includes mobile auth, get_user/get_version, SMS wallet parity endpoints, appearance backfill, and related Prisma migrations.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-30 18:19:53 +03:30

34 lines
758 B
JavaScript

const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function main() {
const rows = await prisma.tenant.findMany({
select: { id: true, notes: true, appVersion: true },
});
let n = 0;
for (const row of rows) {
const match = String(row.notes || '').match(/version:([^|\s]+)/i);
if (!match?.[1]) continue;
if (row.appVersion && row.appVersion !== '1') continue;
await prisma.tenant.update({
where: { id: row.id },
data: { appVersion: match[1].trim() },
});
n += 1;
}
console.log(`backfilled ${n} of ${rows.length}`);
}
main()
.catch((error) => {
console.error(error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});