-- Öğrenci adresi, anne-baba durumu, çoklu veli/yakın iletişim kartları

ALTER TABLE "students" ADD COLUMN "address" TEXT;
ALTER TABLE "students" ADD COLUMN "parents_family_status" TEXT;

CREATE TABLE "student_guardian_contacts" (
    "id" TEXT NOT NULL,
    "tenant_id" TEXT NOT NULL,
    "student_id" TEXT NOT NULL,
    "full_name" TEXT,
    "relation" TEXT NOT NULL,
    "phone" TEXT,
    "address" TEXT,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT "student_guardian_contacts_pkey" PRIMARY KEY ("id")
);

CREATE INDEX "student_guardian_contacts_tenant_id_student_id_idx" ON "student_guardian_contacts"("tenant_id", "student_id");

ALTER TABLE "student_guardian_contacts" ADD CONSTRAINT "student_guardian_contacts_tenant_id_fkey" FOREIGN KEY ("tenant_id") REFERENCES "tenants"("id") ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE "student_guardian_contacts" ADD CONSTRAINT "student_guardian_contacts_student_id_fkey" FOREIGN KEY ("student_id") REFERENCES "students"("id") ON DELETE CASCADE ON UPDATE CASCADE;
