job description file upload

This commit is contained in:
Om Lanke
2025-09-23 01:31:13 +05:30
parent efe81705f5
commit d171d23471
13 changed files with 1992 additions and 30 deletions

View File

@@ -1,12 +1,14 @@
'use server';
import { db, companies, jobs } from '@workspace/db';
import { writeFile, mkdir } from 'fs/promises';
import { join } from 'path';
export async function createJob(formData: FormData) {
const companyIdRaw = formData.get('companyId');
const companyId = companyIdRaw ? Number(companyIdRaw) : undefined;
const title = String(formData.get('title') ?? '').trim();
const link = String(formData.get('link') ?? '').trim();
const description = String(formData.get('description') ?? '').trim() || 'N/A';
const description = String(formData.get('description') ?? '').trim() || '';
const location = String(formData.get('location') ?? '').trim() || 'N/A';
const imageURL =
String(formData.get('imageURL') ?? '').trim() || 'https://via.placeholder.com/100x100?text=Job';
@@ -19,13 +21,49 @@ export async function createJob(formData: FormData) {
const allowDeadKT = formData.get('allowDeadKT') === 'on' || formData.get('allowDeadKT') === 'true';
const allowLiveKT = formData.get('allowLiveKT') === 'on' || formData.get('allowLiveKT') === 'true';
// Handle file upload
const descriptionFile = formData.get('descriptionFile') as File | null;
const fileType = formData.get('fileType') as string | null;
let fileUrl: string | null = null;
let fileName: string | null = null;
if (descriptionFile && descriptionFile.size > 0) {
try {
// Create uploads directory if it doesn't exist
const uploadsDir = join(process.cwd(), 'public', 'uploads', 'job-descriptions');
await mkdir(uploadsDir, { recursive: true });
// Generate unique filename
const timestamp = Date.now();
const originalName = descriptionFile.name.replace(/[^a-zA-Z0-9.-]/g, '_');
fileName = `${timestamp}_${originalName}`;
const filePath = join(uploadsDir, fileName);
// Write file to disk
const bytes = await descriptionFile.arrayBuffer();
await writeFile(filePath, Buffer.from(bytes));
// Set file URL for database
fileUrl = `/uploads/job-descriptions/${fileName}`;
} catch (error) {
console.error('Error uploading file:', error);
return { error: 'Failed to upload description file.' };
}
}
if (!companyId || !title) return { error: 'Company and title are required.' };
// Either description text OR file is required
if (!description && !descriptionFile) {
return { error: 'Either description text or description file is required.' };
}
await db.insert(jobs).values({
companyId,
title,
link,
description,
description: description || null,
location,
imageURL,
salary,
@@ -36,18 +74,20 @@ export async function createJob(formData: FormData) {
minHSC,
allowDeadKT,
allowLiveKT,
fileType: fileType || null,
fileUrl: fileUrl || null,
fileName: fileName || null,
});
return { success: true };
}
export async function createCompany(formData: FormData) {
const name = String(formData.get('name') ?? '').trim();
const email = String(formData.get('email') ?? '').trim();
const link = String(formData.get('link') ?? '').trim();
const description = String(formData.get('description') ?? '').trim();
const imageURL = String(formData.get('imageURL') ?? '').trim() || 'https://via.placeholder.com/100x100?text=Company';
if (!name || !email || !link || !description) return { error: 'All fields are required.' };
const [inserted] = await db.insert(companies).values({ name, email, link, description, imageURL }).returning();
if (!name || !link || !description) return { error: 'Name, link, and description are required.' };
const [inserted] = await db.insert(companies).values({ name, link, description, imageURL }).returning();
if (!inserted) return { error: 'Failed to add company.' };
return { success: true, company: { id: inserted.id, name: inserted.name } };
}

View File

@@ -29,6 +29,9 @@ import {
CheckCircle,
AlertCircle,
LinkIcon,
Upload,
FileText,
X,
} from "lucide-react"
import { cn } from "@workspace/ui/lib/utils"
import { Alert, AlertDescription } from "@workspace/ui/components/alert"
@@ -62,6 +65,8 @@ function NewJobForm({ companies }: { companies: { id: number; name: string }[] }
minHSC: 0,
allowDeadKT: true,
allowLiveKT: true,
fileType: undefined,
descriptionFile: undefined,
},
})
@@ -74,7 +79,7 @@ function NewJobForm({ companies }: { companies: { id: number; name: string }[] }
formData.append('companyId', String(data.companyId))
formData.append('title', data.title)
formData.append('link', data.link)
formData.append('description', data.description)
formData.append('description', data.description || '')
formData.append('location', data.location)
formData.append('imageURL', data.imageURL || '')
formData.append('salary', data.salary)
@@ -89,6 +94,12 @@ function NewJobForm({ companies }: { companies: { id: number; name: string }[] }
formData.append('allowDeadKT', String(data.allowDeadKT))
formData.append('allowLiveKT', String(data.allowLiveKT))
// Handle file upload
if (data.descriptionFile) {
formData.append('descriptionFile', data.descriptionFile)
formData.append('fileType', data.fileType || (data.descriptionFile.type === 'application/pdf' ? 'pdf' : 'text'))
}
const result = await createJob(formData)
if (result?.success) {
setSuccess(true)
@@ -412,23 +423,102 @@ function NewJobForm({ companies }: { companies: { id: number; name: string }[] }
/>
</div>
<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel className="text-sm font-medium text-gray-700">Job Description *</FormLabel>
<FormControl>
<Textarea
placeholder="Describe the role, responsibilities, and requirements..."
{...field}
className="min-h-[120px] resize-none"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* Job Description Section - Text or File */}
<div className="space-y-4">
<FormLabel className="text-sm font-medium text-gray-700">Job Description *</FormLabel>
<p className="text-sm text-gray-600">Provide either a text description or upload a PDF/text file</p>
<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel className="text-sm font-medium text-gray-700">Text Description</FormLabel>
<FormControl>
<Textarea
placeholder="Describe the role, responsibilities, and requirements..."
{...field}
className="min-h-[120px] resize-none"
disabled={!!form.watch('descriptionFile')}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="flex items-center justify-center">
<div className="flex-1 border-t border-gray-300"></div>
<div className="px-3 text-sm text-gray-500 bg-white">OR</div>
<div className="flex-1 border-t border-gray-300"></div>
</div>
<FormField
control={form.control}
name="descriptionFile"
render={({ field: { onChange, value, ...field } }) => (
<FormItem>
<FormLabel className="text-sm font-medium text-gray-700">Upload Description File</FormLabel>
<FormControl>
<div className="space-y-4">
<div className="flex items-center justify-center w-full">
<label className="flex flex-col items-center justify-center w-full h-32 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50 hover:bg-gray-100">
<div className="flex flex-col items-center justify-center pt-5 pb-6">
<Upload className="w-8 h-8 mb-4 text-gray-500" />
<p className="mb-2 text-sm text-gray-500">
<span className="font-semibold">Click to upload</span> or drag and drop
</p>
<p className="text-xs text-gray-500">PDF or TXT (MAX. 5MB)</p>
</div>
<input
type="file"
accept=".pdf,.txt,application/pdf,text/plain"
className="hidden"
onChange={(e) => {
const file = e.target.files?.[0]
if (file) {
onChange(file)
// Auto-detect file type
const fileType = file.type === 'application/pdf' ? 'pdf' : 'text'
form.setValue('fileType', fileType)
// Clear text description
form.setValue('description', '')
}
}}
disabled={!!form.watch('description')?.trim()}
{...field}
/>
</label>
</div>
{value && (
<div className="flex items-center gap-2 p-3 bg-blue-50 rounded-lg border border-blue-200">
<FileText className="w-4 h-4 text-blue-600" />
<span className="text-sm text-blue-800 flex-1">{value.name}</span>
<span className="text-xs text-blue-600">
{(value.size / 1024 / 1024).toFixed(2)} MB
</span>
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => {
onChange(undefined)
form.setValue('fileType', undefined)
}}
className="text-blue-600 hover:text-blue-800"
>
<X className="w-4 h-4" />
</Button>
</div>
)}
</div>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
</div>
{/* Academic Requirements Section */}

View File

@@ -1,10 +1,13 @@
import * as z from 'zod';
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
const ACCEPTED_FILE_TYPES = ['application/pdf', 'text/plain'];
export const jobSchema = z.object({
companyId: z.number().min(1, 'Company is required'),
title: z.string().min(1, 'Title is required'),
link: z.string().url('Invalid URL'),
description: z.string().min(1, 'Description is required'),
description: z.string().optional(), // Made optional since file can replace it
location: z.string().min(1, 'Location is required'),
imageURL: z.string().url('Invalid URL').or(z.literal('')).optional(),
salary: z.string().min(1, 'Salary is required'),
@@ -14,6 +17,21 @@ export const jobSchema = z.object({
minHSC: z.coerce.number().min(0, 'Minimum HSC must be 0 or greater'),
allowDeadKT: z.boolean(),
allowLiveKT: z.boolean(),
});
// File upload fields
fileType: z.enum(['pdf', 'text']).optional(),
descriptionFile: z.instanceof(File)
.refine(file => file?.size <= MAX_FILE_SIZE, 'File size must be less than 5MB')
.refine(file => ACCEPTED_FILE_TYPES.includes(file?.type), 'Only PDF and text files are allowed')
.optional(),
}).refine(
(data) => {
// Either description text OR file is required
return (data.description && data.description.trim().length > 0) || data.descriptionFile;
},
{
message: 'Either provide a text description or upload a description file',
path: ['description'],
}
);
export type JobFormData = z.infer<typeof jobSchema>;

View File

@@ -0,0 +1,45 @@
import { NextRequest, NextResponse } from 'next/server';
import { readFile } from 'fs/promises';
import { join } from 'path';
export async function GET(
request: NextRequest,
{ params }: { params: { filename: string } }
) {
try {
const filename = params.filename;
// Security check - prevent directory traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
return NextResponse.json({ error: 'Invalid filename' }, { status: 400 });
}
const filePath = join(process.cwd(), 'public', 'uploads', 'job-descriptions', filename);
try {
const fileBuffer = await readFile(filePath);
// Determine content type based on file extension
const ext = filename.split('.').pop()?.toLowerCase();
let contentType = 'application/octet-stream';
if (ext === 'pdf') {
contentType = 'application/pdf';
} else if (ext === 'txt') {
contentType = 'text/plain';
}
// Set appropriate headers
const response = new NextResponse(new Uint8Array(fileBuffer));
response.headers.set('Content-Type', contentType);
response.headers.set('Content-Disposition', `inline; filename="${filename}"`);
return response;
} catch (error) {
return NextResponse.json({ error: 'File not found' }, { status: 404 });
}
} catch (error) {
console.error('Error serving file:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}

View File

@@ -31,6 +31,8 @@ import {
ExternalLink,
Loader2,
AlertCircle,
FileText,
Download,
} from 'lucide-react';
import JobApplicationModal from '@/components/job-application-modal';
import { type InferSelectModel } from '@workspace/db/drizzle';
@@ -42,6 +44,68 @@ export type Job = InferSelectModel<typeof jobs> & {
export type Resume = typeof resumes.$inferSelect;
const JobDescription = ({ job }: { job: Job }) => {
if (job.fileUrl && job.fileName) {
const apiFileUrl = `/api/files/job-descriptions/${job.fileName}`;
// Display file information
return (
<div className="mb-4">
<div className="flex items-center gap-3 p-3 bg-blue-50 rounded-lg border border-blue-200">
<FileText className="w-5 h-5 text-blue-600" />
<div className="flex-1">
<p className="text-sm font-medium text-blue-800">Job Description File</p>
<p className="text-xs text-blue-600">{job.fileName}</p>
</div>
<div className="flex gap-2">
{job.fileType === 'pdf' ? (
<Button
size="sm"
variant="outline"
className="text-blue-600 border-blue-300 hover:bg-blue-100"
onClick={() => window.open(apiFileUrl, '_blank')}
>
<Eye className="w-4 h-4 mr-1" />
View PDF
</Button>
) : (
<Button
size="sm"
variant="outline"
className="text-blue-600 border-blue-300 hover:bg-blue-100"
onClick={() => window.open(apiFileUrl, '_blank')}
>
<FileText className="w-4 h-4 mr-1" />
View File
</Button>
)}
<Button
size="sm"
variant="ghost"
className="text-blue-600 hover:bg-blue-100"
onClick={() => {
const link = document.createElement('a');
link.href = apiFileUrl;
link.download = job.fileName!;
link.click();
}}
>
<Download className="w-4 h-4" />
</Button>
</div>
</div>
</div>
);
}
// Display text description
if (job.description) {
return <p className="text-gray-600 text-sm mb-4 line-clamp-2">{job.description}</p>;
}
// Fallback
return <p className="text-gray-500 text-sm mb-4 italic">No description available</p>;
};
export default function JobsPage({
eligibleJobs,
ineligibleJobs,
@@ -77,7 +141,8 @@ export default function JobsPage({
(job) =>
job.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
job.company.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
job.description.toLowerCase().includes(searchTerm.toLowerCase()),
(job.description && job.description.toLowerCase().includes(searchTerm.toLowerCase())) ||
(job.fileName && job.fileName.toLowerCase().includes(searchTerm.toLowerCase())),
);
}
@@ -324,7 +389,7 @@ export default function JobsPage({
</div>
</div>
<p className="text-gray-600 text-sm mb-4 line-clamp-2">{job.description}</p>
<JobDescription job={job} />
<div className="grid grid-cols-2 gap-4 mb-4">
<div className="flex items-center gap-2 text-sm text-gray-600">
@@ -341,7 +406,7 @@ export default function JobsPage({
<div className="flex gap-2">
{activeTab === 'eligible' ? (
<JobApplicationModal
job={{ ...job, minCGPA: Number(job.minCGPA) }}
job={job}
studentId={studentId}
resumes={resumes}
isApplied={appliedJobIds.includes(job.id)}

View File

@@ -0,0 +1,46 @@
import { NextRequest, NextResponse } from 'next/server';
import { readFile } from 'fs/promises';
import { join } from 'path';
import { headers } from 'next/headers';
export async function GET(
request: NextRequest,
{ params }: { params: { filename: string } }
) {
try {
const filename = params.filename;
// Security check - prevent directory traversal
if (filename.includes('..') || filename.includes('/') || filename.includes('\\')) {
return NextResponse.json({ error: 'Invalid filename' }, { status: 400 });
}
const filePath = join(process.cwd(), 'public', 'uploads', 'job-descriptions', filename);
try {
const fileBuffer = await readFile(filePath);
// Determine content type based on file extension
const ext = filename.split('.').pop()?.toLowerCase();
let contentType = 'application/octet-stream';
if (ext === 'pdf') {
contentType = 'application/pdf';
} else if (ext === 'txt') {
contentType = 'text/plain';
}
// Set appropriate headers
const response = new NextResponse(new Uint8Array(fileBuffer));
response.headers.set('Content-Type', contentType);
response.headers.set('Content-Disposition', `inline; filename="${filename}"`);
return response;
} catch (error) {
return NextResponse.json({ error: 'File not found' }, { status: 404 });
}
} catch (error) {
console.error('Error serving file:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}

View File

@@ -28,7 +28,7 @@ export type Job = InferSelectModel<typeof jobs> & {
export type Resume = typeof resumes.$inferSelect;
interface JobApplicationModalProps {
job: Job & { minCGPA: number };
job: Job;
studentId: number;
resumes: Resume[];
isApplied?: boolean;

View File

@@ -0,0 +1,3 @@
ALTER TABLE "jobs" ADD COLUMN "fileType" varchar(10);--> statement-breakpoint
ALTER TABLE "jobs" ADD COLUMN "fileUrl" text;--> statement-breakpoint
ALTER TABLE "jobs" ADD COLUMN "fileName" text;

View File

@@ -0,0 +1 @@
ALTER TABLE "jobs" ALTER COLUMN "description" DROP NOT NULL;

View File

@@ -0,0 +1,818 @@
{
"id": "ad17dff5-44b7-4371-80cc-730b3792bfe3",
"prevId": "41b7ecf1-42ee-4436-b4d6-6f721cbe9f6d",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.admins": {
"name": "admins",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"admins_email_unique": {
"name": "admins_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.applications": {
"name": "applications",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"jobId": {
"name": "jobId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"resumeId": {
"name": "resumeId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'pending'"
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"applications_jobId_jobs_id_fk": {
"name": "applications_jobId_jobs_id_fk",
"tableFrom": "applications",
"tableTo": "jobs",
"columnsFrom": [
"jobId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_studentId_students_id_fk": {
"name": "applications_studentId_students_id_fk",
"tableFrom": "applications",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_resumeId_resumes_id_fk": {
"name": "applications_resumeId_resumes_id_fk",
"tableFrom": "applications",
"tableTo": "resumes",
"columnsFrom": [
"resumeId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.companies": {
"name": "companies",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"imageURL": {
"name": "imageURL",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.grades": {
"name": "grades",
"schema": "",
"columns": {
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"sem": {
"name": "sem",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"sgpi": {
"name": "sgpi",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true
},
"isKT": {
"name": "isKT",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"deadKT": {
"name": "deadKT",
"type": "boolean",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"grades_studentId_students_id_fk": {
"name": "grades_studentId_students_id_fk",
"tableFrom": "grades",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"grades_studentId_sem_pk": {
"name": "grades_studentId_sem_pk",
"columns": [
"studentId",
"sem"
]
}
},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {
"sem_check1": {
"name": "sem_check1",
"value": "\"grades\".\"sem\" < 9"
}
},
"isRLSEnabled": false
},
"public.internships": {
"name": "internships",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"company": {
"name": "company",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"location": {
"name": "location",
"type": "text",
"primaryKey": false,
"notNull": true
},
"startDate": {
"name": "startDate",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"endDate": {
"name": "endDate",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"internships_studentId_students_id_fk": {
"name": "internships_studentId_students_id_fk",
"tableFrom": "internships",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.jobs": {
"name": "jobs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"companyId": {
"name": "companyId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"location": {
"name": "location",
"type": "text",
"primaryKey": false,
"notNull": true
},
"imageURL": {
"name": "imageURL",
"type": "text",
"primaryKey": false,
"notNull": true
},
"salary": {
"name": "salary",
"type": "text",
"primaryKey": false,
"notNull": true
},
"applicationDeadline": {
"name": "applicationDeadline",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"active": {
"name": "active",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"minCGPA": {
"name": "minCGPA",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"minSSC": {
"name": "minSSC",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"minHSC": {
"name": "minHSC",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"allowDeadKT": {
"name": "allowDeadKT",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"allowLiveKT": {
"name": "allowLiveKT",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"fileType": {
"name": "fileType",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"fileUrl": {
"name": "fileUrl",
"type": "text",
"primaryKey": false,
"notNull": false
},
"fileName": {
"name": "fileName",
"type": "text",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"jobs_companyId_companies_id_fk": {
"name": "jobs_companyId_companies_id_fk",
"tableFrom": "jobs",
"tableTo": "companies",
"columnsFrom": [
"companyId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.resumes": {
"name": "resumes",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"resumes_studentId_students_id_fk": {
"name": "resumes_studentId_students_id_fk",
"tableFrom": "resumes",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.students": {
"name": "students",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"rollNumber": {
"name": "rollNumber",
"type": "varchar(12)",
"primaryKey": false,
"notNull": false
},
"verified": {
"name": "verified",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"markedOut": {
"name": "markedOut",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"firstName": {
"name": "firstName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"middleName": {
"name": "middleName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"lastName": {
"name": "lastName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"mothersName": {
"name": "mothersName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"mothersEmail": {
"name": "mothersEmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"mothersPhone": {
"name": "mothersPhone",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"fathersName": {
"name": "fathersName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"fathersEmail": {
"name": "fathersEmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"fathersPhone": {
"name": "fathersPhone",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"gender": {
"name": "gender",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"dob": {
"name": "dob",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"personalGmail": {
"name": "personalGmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"phoneNumber": {
"name": "phoneNumber",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"profilePicture": {
"name": "profilePicture",
"type": "text",
"primaryKey": false,
"notNull": false
},
"degree": {
"name": "degree",
"type": "text",
"primaryKey": false,
"notNull": false
},
"branch": {
"name": "branch",
"type": "text",
"primaryKey": false,
"notNull": false
},
"year": {
"name": "year",
"type": "text",
"primaryKey": false,
"notNull": false
},
"skills": {
"name": "skills",
"type": "text[]",
"primaryKey": false,
"notNull": false,
"default": "ARRAY[]::text[]"
},
"linkedin": {
"name": "linkedin",
"type": "text",
"primaryKey": false,
"notNull": false
},
"github": {
"name": "github",
"type": "text",
"primaryKey": false,
"notNull": false
},
"ssc": {
"name": "ssc",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": false
},
"hsc": {
"name": "hsc",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": false
},
"isDiploma": {
"name": "isDiploma",
"type": "boolean",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -0,0 +1,818 @@
{
"id": "35b32f42-74bf-4935-9354-d4c8824cebc1",
"prevId": "ad17dff5-44b7-4371-80cc-730b3792bfe3",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.admins": {
"name": "admins",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"admins_email_unique": {
"name": "admins_email_unique",
"nullsNotDistinct": false,
"columns": [
"email"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.applications": {
"name": "applications",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"jobId": {
"name": "jobId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"resumeId": {
"name": "resumeId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"status": {
"name": "status",
"type": "text",
"primaryKey": false,
"notNull": true,
"default": "'pending'"
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"applications_jobId_jobs_id_fk": {
"name": "applications_jobId_jobs_id_fk",
"tableFrom": "applications",
"tableTo": "jobs",
"columnsFrom": [
"jobId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_studentId_students_id_fk": {
"name": "applications_studentId_students_id_fk",
"tableFrom": "applications",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_resumeId_resumes_id_fk": {
"name": "applications_resumeId_resumes_id_fk",
"tableFrom": "applications",
"tableTo": "resumes",
"columnsFrom": [
"resumeId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.companies": {
"name": "companies",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"imageURL": {
"name": "imageURL",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.grades": {
"name": "grades",
"schema": "",
"columns": {
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"sem": {
"name": "sem",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"sgpi": {
"name": "sgpi",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true
},
"isKT": {
"name": "isKT",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"deadKT": {
"name": "deadKT",
"type": "boolean",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"grades_studentId_students_id_fk": {
"name": "grades_studentId_students_id_fk",
"tableFrom": "grades",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"grades_studentId_sem_pk": {
"name": "grades_studentId_sem_pk",
"columns": [
"studentId",
"sem"
]
}
},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {
"sem_check1": {
"name": "sem_check1",
"value": "\"grades\".\"sem\" < 9"
}
},
"isRLSEnabled": false
},
"public.internships": {
"name": "internships",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"company": {
"name": "company",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"location": {
"name": "location",
"type": "text",
"primaryKey": false,
"notNull": true
},
"startDate": {
"name": "startDate",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"endDate": {
"name": "endDate",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"internships_studentId_students_id_fk": {
"name": "internships_studentId_students_id_fk",
"tableFrom": "internships",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.jobs": {
"name": "jobs",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"companyId": {
"name": "companyId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
},
"location": {
"name": "location",
"type": "text",
"primaryKey": false,
"notNull": true
},
"imageURL": {
"name": "imageURL",
"type": "text",
"primaryKey": false,
"notNull": true
},
"salary": {
"name": "salary",
"type": "text",
"primaryKey": false,
"notNull": true
},
"applicationDeadline": {
"name": "applicationDeadline",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"active": {
"name": "active",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"minCGPA": {
"name": "minCGPA",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"minSSC": {
"name": "minSSC",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"minHSC": {
"name": "minHSC",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0'"
},
"allowDeadKT": {
"name": "allowDeadKT",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"allowLiveKT": {
"name": "allowLiveKT",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": true
},
"fileType": {
"name": "fileType",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"fileUrl": {
"name": "fileUrl",
"type": "text",
"primaryKey": false,
"notNull": false
},
"fileName": {
"name": "fileName",
"type": "text",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"jobs_companyId_companies_id_fk": {
"name": "jobs_companyId_companies_id_fk",
"tableFrom": "jobs",
"tableTo": "companies",
"columnsFrom": [
"companyId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.resumes": {
"name": "resumes",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"studentId": {
"name": "studentId",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": true
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"resumes_studentId_students_id_fk": {
"name": "resumes_studentId_students_id_fk",
"tableFrom": "resumes",
"tableTo": "students",
"columnsFrom": [
"studentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.students": {
"name": "students",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"rollNumber": {
"name": "rollNumber",
"type": "varchar(12)",
"primaryKey": false,
"notNull": false
},
"verified": {
"name": "verified",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"markedOut": {
"name": "markedOut",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"firstName": {
"name": "firstName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"middleName": {
"name": "middleName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"lastName": {
"name": "lastName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"mothersName": {
"name": "mothersName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"mothersEmail": {
"name": "mothersEmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"mothersPhone": {
"name": "mothersPhone",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"fathersName": {
"name": "fathersName",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"fathersEmail": {
"name": "fathersEmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"fathersPhone": {
"name": "fathersPhone",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"gender": {
"name": "gender",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"dob": {
"name": "dob",
"type": "timestamp",
"primaryKey": false,
"notNull": false
},
"personalGmail": {
"name": "personalGmail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"phoneNumber": {
"name": "phoneNumber",
"type": "varchar(10)",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "text",
"primaryKey": false,
"notNull": false
},
"profilePicture": {
"name": "profilePicture",
"type": "text",
"primaryKey": false,
"notNull": false
},
"degree": {
"name": "degree",
"type": "text",
"primaryKey": false,
"notNull": false
},
"branch": {
"name": "branch",
"type": "text",
"primaryKey": false,
"notNull": false
},
"year": {
"name": "year",
"type": "text",
"primaryKey": false,
"notNull": false
},
"skills": {
"name": "skills",
"type": "text[]",
"primaryKey": false,
"notNull": false,
"default": "ARRAY[]::text[]"
},
"linkedin": {
"name": "linkedin",
"type": "text",
"primaryKey": false,
"notNull": false
},
"github": {
"name": "github",
"type": "text",
"primaryKey": false,
"notNull": false
},
"ssc": {
"name": "ssc",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": false
},
"hsc": {
"name": "hsc",
"type": "numeric(4, 2)",
"primaryKey": false,
"notNull": false
},
"isDiploma": {
"name": "isDiploma",
"type": "boolean",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@@ -71,6 +71,20 @@
"when": 1758549147237,
"tag": "0009_wealthy_chronomancer",
"breakpoints": true
},
{
"idx": 10,
"version": "7",
"when": 1758568071620,
"tag": "0010_nappy_avengers",
"breakpoints": true
},
{
"idx": 11,
"version": "7",
"when": 1758570908922,
"tag": "0011_gifted_cammi",
"breakpoints": true
}
]
}

View File

@@ -206,7 +206,7 @@ export const jobs = pgTable('jobs', {
.references(() => companies.id),
title: text().notNull(),
link: text().notNull(),
description: text().notNull(),
description: text(), // Made nullable since we can have file uploads instead
location: text().notNull(),
imageURL: text().notNull(),
salary: text().notNull(),
@@ -217,6 +217,10 @@ export const jobs = pgTable('jobs', {
minHSC: numeric({ precision: 4, scale: 2 }).notNull().default('0'),
allowDeadKT: boolean().notNull().default(true),
allowLiveKT: boolean().notNull().default(true),
// File upload fields for job description
fileType: varchar({ length: 10 }), // 'pdf' or 'text' or null for regular description
fileUrl: text(), // URL to uploaded file
fileName: text(), // Original filename
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp()
.defaultNow()