-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Etudiant" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "nom" TEXT NOT NULL,
    "prenom" TEXT NOT NULL,
    "cin" TEXT NOT NULL,
    "dateNaissance" DATETIME,
    "telephone" TEXT NOT NULL,
    "email" TEXT,
    "adresse" TEXT,
    "photo" TEXT,
    "filiereId" INTEGER NOT NULL,
    "niveau" TEXT NOT NULL,
    "dateInscription" DATETIME NOT NULL,
    "anneeScolaireId" INTEGER NOT NULL,
    "statut" TEXT NOT NULL DEFAULT 'ACTIF',
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT "Etudiant_filiereId_fkey" FOREIGN KEY ("filiereId") REFERENCES "Filiere" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
    CONSTRAINT "Etudiant_anneeScolaireId_fkey" FOREIGN KEY ("anneeScolaireId") REFERENCES "AnneeScolaire" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_Etudiant" ("adresse", "anneeScolaireId", "cin", "createdAt", "dateInscription", "dateNaissance", "email", "filiereId", "id", "niveau", "nom", "photo", "prenom", "statut", "telephone") SELECT "adresse", "anneeScolaireId", "cin", "createdAt", "dateInscription", "dateNaissance", "email", "filiereId", "id", "niveau", "nom", "photo", "prenom", "statut", "telephone" FROM "Etudiant";
DROP TABLE "Etudiant";
ALTER TABLE "new_Etudiant" RENAME TO "Etudiant";
CREATE UNIQUE INDEX "Etudiant_cin_key" ON "Etudiant"("cin");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
