2025-12-06 17:48:10 +03:30
|
|
|
|
import { prisma } from '../src/lib/prisma'
|
|
|
|
|
|
|
|
|
|
|
|
async function main() {
|
2025-12-14 10:15:57 +03:30
|
|
|
|
if ((await prisma.role.count()) === 0) {
|
|
|
|
|
|
await prisma.role.upsert({
|
|
|
|
|
|
where: { id: 0, name: 'Admin' },
|
|
|
|
|
|
update: {},
|
|
|
|
|
|
create: {
|
|
|
|
|
|
name: 'Admin',
|
|
|
|
|
|
},
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-12-06 17:48:10 +03:30
|
|
|
|
|
2025-12-14 10:15:57 +03:30
|
|
|
|
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',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-12-06 17:48:10 +03:30
|
|
|
|
}
|
2025-12-14 10:15:57 +03:30
|
|
|
|
|
2025-12-06 17:48:10 +03:30
|
|
|
|
main()
|
|
|
|
|
|
.then(async () => {
|
|
|
|
|
|
await prisma.$disconnect()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(async e => {
|
|
|
|
|
|
console.error(e)
|
|
|
|
|
|
await prisma.$disconnect()
|
|
|
|
|
|
process.exit(1)
|
|
|
|
|
|
})
|