-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set up company request schema and status
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { relations, sql } from "drizzle-orm"; | ||
import { pgTable, text, timestamp, uuid, varchar } from "drizzle-orm/pg-core"; | ||
import { createInsertSchema } from "drizzle-zod"; | ||
import { z } from "zod"; | ||
|
||
import { Industry, RequestStatus } from "./misc"; | ||
|
||
export const CompanyRequest = pgTable("company_request", { | ||
id: uuid("id").notNull().primaryKey().defaultRandom(), | ||
companyName: varchar("name").notNull(), | ||
companyDescription: text("description"), | ||
industry: varchar("industry").notNull(), | ||
location: varchar("location").notNull(), | ||
roleTitle: varchar("title").notNull(), | ||
roleDescription: text("description"), | ||
createdAt: timestamp("createdAt").defaultNow().notNull(), | ||
updatedAt: timestamp("updatedAt", { | ||
mode: "date", | ||
withTimezone: true, | ||
}).$onUpdateFn(() => sql`now()`), | ||
status: varchar("status", { | ||
enum: ["PENDING", "APPROVED", "REJECTED"], // Explicitly list the enum values | ||
}) | ||
.notNull() | ||
.default("PENDING"), | ||
}); | ||
|
||
export type CompanyRequestType = typeof CompanyRequest.$inferSelect; | ||
|
||
// export const RequestRelations = relations(Role, ({ one }) => ({ | ||
// company: one(Company, { | ||
// fields: [Role.companyId], | ||
// references: [Company.id], | ||
// }), | ||
// roles: one(Role), | ||
// })); | ||
|
||
// Zod validation schema for creating a company request | ||
export const CreateCompanyRequestSchema = createInsertSchema(CompanyRequest, { | ||
companyName: z.string(), | ||
companyDescription: z.string().optional(), | ||
industry: z.nativeEnum(Industry), | ||
location: z.string(), | ||
roleTitle: z.string(), | ||
roleDescription: z.string(), | ||
status: z.nativeEnum(RequestStatus), | ||
}).omit({ | ||
id: true, | ||
createdAt: true, | ||
updatedAt: true, | ||
}); | ||
// Example TypeScript type for the Company Request |