first commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "students" (
|
||||
"student_id" SERIAL NOT NULL,
|
||||
"student_first_name" TEXT NOT NULL,
|
||||
"student_last_name" TEXT NOT NULL,
|
||||
"student_class_name" TEXT,
|
||||
"student_rfid_card_uid" TEXT NOT NULL,
|
||||
"student_card_is_active" BOOLEAN NOT NULL DEFAULT true,
|
||||
|
||||
CONSTRAINT "students_pkey" PRIMARY KEY ("student_id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "attendance_logs" (
|
||||
"attendance_log_id" SERIAL NOT NULL,
|
||||
"student_id" INTEGER NOT NULL,
|
||||
"attendance_scanned_at" TIMESTAMP(3) NOT NULL,
|
||||
"attendance_event_type" TEXT NOT NULL,
|
||||
"was_manual_entry" BOOLEAN NOT NULL DEFAULT false,
|
||||
"manual_entry_reason" TEXT,
|
||||
|
||||
CONSTRAINT "attendance_logs_pkey" PRIMARY KEY ("attendance_log_id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "students_student_rfid_card_uid_key" ON "students"("student_rfid_card_uid");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "attendance_logs_student_id_attendance_scanned_at_idx" ON "attendance_logs"("student_id", "attendance_scanned_at");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "attendance_logs" ADD CONSTRAINT "attendance_logs_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students"("student_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user