Add SQL query for average cost retrieval and generate TriggerLog model

This commit is contained in:
2025-12-14 10:15:57 +03:30
parent 41d7dd8802
commit 9d7d94b5f8
45 changed files with 3742 additions and 440 deletions
+66 -8
View File
@@ -1,16 +1,74 @@
import { prisma } from '../src/lib/prisma'
async function main() {
console.log('first')
if ((await prisma.role.count()) === 0) {
await prisma.role.upsert({
where: { id: 0, name: 'Admin' },
update: {},
create: {
name: 'Admin',
},
})
}
await prisma.role.upsert({
where: { id: 0, name: 'Admin' },
update: {},
create: {
name: 'Admin',
},
})
if ((await prisma.inventory.count()) === 0) {
await prisma.inventory.createMany({
data: [
{ name: 'انبار مرکزی', location: 'تهران', isPointOfSale: false, isActive: true },
{
name: 'فروشگاه حضوری',
location: 'مرکز شهر',
isPointOfSale: true,
isActive: true,
},
{
name: 'فروشگاه اینترنتی',
location: 'مرکز شهر',
isPointOfSale: true,
isActive: true,
},
],
})
}
if ((await prisma.productCategory.count()) === 0) {
await prisma.productCategory.createMany({
data: [{ name: 'دسته‌ی ۱' }, { name: 'دسته‌ی ۲' }, { name: 'دسته‌ی ۳' }],
})
}
if ((await prisma.productBrand.count()) === 0) {
await prisma.productBrand.createMany({
data: [{ name: 'برند ۱' }, { name: 'برند ۲' }, { name: 'برند ۳' }],
})
}
if ((await prisma.supplier.count()) === 0) {
await prisma.supplier.createMany({
data: [
{
firstName: 'تامین‌',
lastName: 'کننده ۱',
mobileNumber: '09120000001',
email: 'supplier1@example.com',
},
{
firstName: 'تامین‌',
lastName: 'کننده ۲',
mobileNumber: '09120000002',
email: 'supplier2@example.com',
},
{
firstName: 'تامین‌',
lastName: 'کننده 3',
mobileNumber: '09120000003',
email: 'supplier3@example.com',
},
],
})
}
}
main()
.then(async () => {
await prisma.$disconnect()