Enhance company types management: updated schema to include display order and relationships, modified validation to use company type XID, and seeded initial company types data. Updated services to reflect new structure and ensure proper data handling.
This commit is contained in:
@@ -405,12 +405,15 @@ model FoodCuisines {
|
||||
}
|
||||
|
||||
model CompanyTypes {
|
||||
id Int @id @default(autoincrement())
|
||||
companyTypeName String @unique @map("company_type_name") @db.VarChar(30)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
id Int @id @default(autoincrement())
|
||||
companyTypeName String @unique @map("company_type_name") @db.VarChar(100)
|
||||
displayOrder Int @map("display_order")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
hostHeaders HostHeader[]
|
||||
hostParents HostParent[]
|
||||
|
||||
@@map("company_types")
|
||||
@@schema("mst")
|
||||
@@ -664,12 +667,13 @@ model HostHeader {
|
||||
panNumber String? @map("pan_number") @db.VarChar(30)
|
||||
gstNumber String? @map("gst_number") @db.VarChar(30)
|
||||
formationDate DateTime? @map("formation_date")
|
||||
companyType String? @map("company_type") @db.VarChar(30)
|
||||
websiteUrl String? @map("website_url") @db.VarChar(50)
|
||||
instagramUrl String? @map("instagram_url") @db.VarChar(80)
|
||||
facebookUrl String? @map("facebook_url") @db.VarChar(80)
|
||||
linkedinUrl String? @map("linkedin_url") @db.VarChar(80)
|
||||
twitterUrl String? @map("twitter_url") @db.VarChar(80)
|
||||
companyTypeXid Int? @map("company_type_xid")
|
||||
companyTypes CompanyTypes? @relation(fields: [companyTypeXid], references: [id], onDelete: Restrict)
|
||||
websiteUrl String? @map("website_url") @db.VarChar(250)
|
||||
instagramUrl String? @map("instagram_url") @db.VarChar(250)
|
||||
facebookUrl String? @map("facebook_url") @db.VarChar(250)
|
||||
linkedinUrl String? @map("linkedin_url") @db.VarChar(250)
|
||||
twitterUrl String? @map("twitter_url") @db.VarChar(250)
|
||||
currencyXid Int? @map("currency_xid")
|
||||
currencies Currencies? @relation(fields: [currencyXid], references: [id], onDelete: Restrict)
|
||||
stepper Int? @default(1) @map("stepper")
|
||||
@@ -785,12 +789,13 @@ model HostParent {
|
||||
panNumber String? @map("pan_number") @db.VarChar(30)
|
||||
gstNumber String? @map("gst_number") @db.VarChar(30)
|
||||
formationDate DateTime? @map("formation_date")
|
||||
companyType String? @map("company_type") @db.VarChar(30)
|
||||
websiteUrl String? @map("website_url") @db.VarChar(80)
|
||||
instagramUrl String? @map("instagram_url") @db.VarChar(80)
|
||||
facebookUrl String? @map("facebook_url") @db.VarChar(80)
|
||||
linkedinUrl String? @map("linkedin_url") @db.VarChar(80)
|
||||
twitterUrl String? @map("twitter_url") @db.VarChar(80)
|
||||
companyTypeXid Int? @map("company_type_xid")
|
||||
companyTypes CompanyTypes? @relation(fields: [companyTypeXid], references: [id], onDelete: Restrict)
|
||||
websiteUrl String? @map("website_url") @db.VarChar(250)
|
||||
instagramUrl String? @map("instagram_url") @db.VarChar(250)
|
||||
facebookUrl String? @map("facebook_url") @db.VarChar(250)
|
||||
linkedinUrl String? @map("linkedin_url") @db.VarChar(250)
|
||||
twitterUrl String? @map("twitter_url") @db.VarChar(250)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import 'dotenv/config';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
const prisma = new PrismaClient({
|
||||
adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL }),
|
||||
});
|
||||
|
||||
async function main() {
|
||||
// ✅ Countries
|
||||
@@ -133,6 +137,43 @@ async function main() {
|
||||
skipDuplicates: true, // prevents error if already seeded
|
||||
});
|
||||
|
||||
// ✅ Company types data
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'Proprietory' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'Proprietory', displayOrder: 1 },
|
||||
});
|
||||
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'One Person Company' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'One Person Company', displayOrder: 2 },
|
||||
});
|
||||
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'Limited Liability Partnership' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'Limited Liability Partnership', displayOrder: 3 },
|
||||
});
|
||||
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'Partnership Firm' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'Partnership Firm', displayOrder: 4 },
|
||||
});
|
||||
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'Private Limited, Public Limited' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'Private Limited, Public Limited', displayOrder: 5 },
|
||||
});
|
||||
|
||||
await prisma.companyTypes.upsert({
|
||||
where: { companyTypeName: 'Non-Profit Organisation' },
|
||||
update: {},
|
||||
create: { companyTypeName: 'Non-Profit Organisation', displayOrder: 6 },
|
||||
});
|
||||
|
||||
// ✅ Food Types
|
||||
await prisma.foodTypes.createMany({
|
||||
data: [
|
||||
|
||||
Reference in New Issue
Block a user