refactor user accounts structure

This commit is contained in:
2026-03-16 00:33:40 +03:30
parent d2215b9f04
commit 0ad6a3200e
118 changed files with 18774 additions and 8764 deletions
+52 -12
View File
@@ -3,25 +3,65 @@ import { prisma } from '../src/lib/prisma'
async function main() {
const password = await PasswordUtil.hash('123456')
const adminUser = await prisma.account.upsert({
where: { username: 'superAdmin' },
const adminUser = await prisma.admin.upsert({
where: {
mobile_number: '09120258156',
},
update: {},
create: {
username: 'superAdmin',
password,
type: 'ADMIN',
status: 'ACTIVE',
updated_at: new Date(),
user: {
first_name: 'عباس',
last_name: 'حسنی',
national_code: '0016022289',
mobile_number: '09120258156',
accounts: {
create: {
first_name: 'عباس',
last_name: 'حسنی',
national_code: '0016022289',
mobile_number: '09120258156',
account: {
create: {
username: 'superAdmin',
password,
type: 'ADMIN',
status: 'ACTIVE',
},
},
},
},
},
})
const guildsCount = prisma.guild.count()
if (!guildsCount) {
const guilds = await prisma.guild.createMany({
data: [
{
name: 'طلا',
code: 'Gold',
},
{
name: 'میوه و تره‌بار',
code: 'Fruit',
},
],
})
const goldGuildId = guilds[0].id
const categoryFactory = (name: string) => ({
name,
guild_id: goldGuildId,
is_default_guild_good: true,
})
await prisma.goodCategory.createMany({
data: [
categoryFactory('زیورآلات'),
categoryFactory('طلا'),
categoryFactory('سایر'),
categoryFactory('سکه'),
categoryFactory('شمش'),
categoryFactory('شمش'),
],
})
}
}
main()