refactor user accounts structure
This commit is contained in:
+52
-12
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user