-- CreateEnum
CREATE TYPE "UserStatus" AS ENUM ('AKTIF', 'KELUAR', 'TAMAT', 'NONAKTIF');

-- CreateEnum
CREATE TYPE "MutasiType" AS ENUM ('KELUAR', 'TAMAT', 'NAIK_KELAS', 'PINDAH_KELAS');

-- AlterTable
ALTER TABLE "users" ADD COLUMN     "jurusanId" TEXT,
ADD COLUMN     "kelas" TEXT,
ADD COLUMN     "name" TEXT,
ADD COLUMN     "nisn" TEXT,
ADD COLUMN     "status" "UserStatus" NOT NULL DEFAULT 'AKTIF';

-- CreateTable
CREATE TABLE "mutasi_siswa" (
    "id" TEXT NOT NULL,
    "siswaId" TEXT NOT NULL,
    "type" "MutasiType" NOT NULL,
    "alasan" TEXT NOT NULL,
    "tanggal" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "dariKelas" TEXT,
    "keKelas" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "mutasi_siswa_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "users" ADD CONSTRAINT "users_jurusanId_fkey" FOREIGN KEY ("jurusanId") REFERENCES "jurusan"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "mutasi_siswa" ADD CONSTRAINT "mutasi_siswa_siswaId_fkey" FOREIGN KEY ("siswaId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
