experimental form

This commit is contained in:
Om Lanke
2025-06-25 17:51:25 +05:30
parent 7645889297
commit e82685c7df
18 changed files with 2801 additions and 27 deletions

View File

@@ -0,0 +1,3 @@
ALTER TABLE "grades" DROP COLUMN "id";--> statement-breakpoint
ALTER TABLE "grades" ADD CONSTRAINT "grades_student_id_sem_pk" PRIMARY KEY("student_id","sem");--> statement-breakpoint
ALTER TABLE "grades" ADD CONSTRAINT "sem_check1" CHECK ("grades"."sem" < 9);

View File

@@ -0,0 +1,900 @@
{
"id": "a00a32a1-83c4-49c8-b7b5-ff990facf461",
"prevId": "fecbaf55-79f1-48f7-bfc2-e8e1a35c89cf",
"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
},
"job_id": {
"name": "job_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"student_id": {
"name": "student_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"resume_id": {
"name": "resume_id",
"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_job_id_jobs_id_fk": {
"name": "applications_job_id_jobs_id_fk",
"tableFrom": "applications",
"tableTo": "jobs",
"columnsFrom": [
"job_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_student_id_students_id_fk": {
"name": "applications_student_id_students_id_fk",
"tableFrom": "applications",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"applications_resume_id_resumes_id_fk": {
"name": "applications_resume_id_resumes_id_fk",
"tableFrom": "applications",
"tableTo": "resumes",
"columnsFrom": [
"resume_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.certificates": {
"name": "certificates",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"student_id": {
"name": "student_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"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": {
"certificates_student_id_students_id_fk": {
"name": "certificates_student_id_students_id_fk",
"tableFrom": "certificates",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"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
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true
},
"link": {
"name": "link",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"passwordHash": {
"name": "passwordHash",
"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": {
"student_id": {
"name": "student_id",
"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_student_id_students_id_fk": {
"name": "grades_student_id_students_id_fk",
"tableFrom": "grades",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"grades_student_id_sem_pk": {
"name": "grades_student_id_sem_pk",
"columns": [
"student_id",
"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
},
"student_id": {
"name": "student_id",
"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
},
"status": {
"name": "status",
"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": {
"internships_student_id_students_id_fk": {
"name": "internships_student_id_students_id_fk",
"tableFrom": "internships",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"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
},
"company_id": {
"name": "company_id",
"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
},
"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_company_id_companies_id_fk": {
"name": "jobs_company_id_companies_id_fk",
"tableFrom": "jobs",
"tableTo": "companies",
"columnsFrom": [
"company_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.projects": {
"name": "projects",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"student_id": {
"name": "student_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"links": {
"name": "links",
"type": "text[]",
"primaryKey": false,
"notNull": true,
"default": "ARRAY[]::text[]"
},
"createdAt": {
"name": "createdAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updatedAt": {
"name": "updatedAt",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"projects_student_id_students_id_fk": {
"name": "projects_student_id_students_id_fk",
"tableFrom": "projects",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"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
},
"student_id": {
"name": "student_id",
"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_student_id_students_id_fk": {
"name": "resumes_student_id_students_id_fk",
"tableFrom": "resumes",
"tableTo": "students",
"columnsFrom": [
"student_id"
],
"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
},
"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
},
"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
},
"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

@@ -22,6 +22,13 @@
"when": 1750660274923,
"tag": "0002_flowery_silver_surfer",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1750849519081,
"tag": "0003_clammy_shadowcat",
"breakpoints": true
}
]
}

View File

@@ -8,6 +8,8 @@ import {
timestamp,
integer,
numeric,
primaryKey,
check
} from "drizzle-orm/pg-core";
export const students = pgTable("students", {
@@ -32,6 +34,7 @@ export const students = pgTable("students", {
github: text(),
ssc: numeric({ precision: 4, scale: 2 }),
hsc: numeric({ precision: 4, scale: 2 }),
isDiploma: boolean(),
createdAt: timestamp().notNull().defaultNow(),
updatedAt: timestamp()
.defaultNow()
@@ -106,7 +109,6 @@ export const resumes = pgTable("resumes", {
});
export const grades = pgTable("grades", {
id: serial().primaryKey(),
studentId: integer("student_id")
.notNull()
.references(() => students.id),
@@ -119,7 +121,7 @@ export const grades = pgTable("grades", {
.defaultNow()
.$onUpdate(() => new Date())
.notNull(),
});
}, (table) => [primaryKey({ columns: [table.studentId, table.sem] }), check("sem_check1", sql`${table.sem} < 9`)]);
export const studentRelations = relations(students, ({ many }) => ({
internships: many(internships),