feat(db): add CarteEtudiante model
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
BEGIN TRY
|
||||||
|
|
||||||
|
BEGIN TRAN;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE [dbo].[carte_etudiante] (
|
||||||
|
[id] INT NOT NULL IDENTITY(1,1),
|
||||||
|
[utilisateur_id] INT NOT NULL,
|
||||||
|
[qr_code] NVARCHAR(1000) NOT NULL,
|
||||||
|
[date_activation] DATETIME2 NOT NULL,
|
||||||
|
[date_expiration] DATETIME2 NOT NULL,
|
||||||
|
[actif] BIT NOT NULL CONSTRAINT [carte_etudiante_actif_df] DEFAULT 1,
|
||||||
|
[created_at] DATETIME2 NOT NULL CONSTRAINT [carte_etudiante_created_at_df] DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
[updated_at] DATETIME2 NOT NULL,
|
||||||
|
CONSTRAINT [carte_etudiante_pkey] PRIMARY KEY CLUSTERED ([id])
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE [dbo].[carte_etudiante] ADD CONSTRAINT [carte_etudiante_utilisateur_id_fkey] FOREIGN KEY ([utilisateur_id]) REFERENCES [dbo].[utilisateur]([id]) ON DELETE NO ACTION ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
COMMIT TRAN;
|
||||||
|
|
||||||
|
END TRY
|
||||||
|
BEGIN CATCH
|
||||||
|
|
||||||
|
IF @@TRANCOUNT > 0
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK TRAN;
|
||||||
|
END;
|
||||||
|
THROW
|
||||||
|
|
||||||
|
END CATCH
|
||||||
@@ -43,8 +43,9 @@ model Utilisateur {
|
|||||||
actif Boolean @default(true)
|
actif Boolean @default(true)
|
||||||
createdAt DateTime @default(now()) @map("created_at")
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
updatedAt DateTime @updatedAt @map("updated_at")
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
campus Campus @relation(fields: [campusId], references: [id])
|
campus Campus @relation(fields: [campusId], references: [id])
|
||||||
role Role @relation(fields: [roleId], references: [id])
|
role Role @relation(fields: [roleId], references: [id])
|
||||||
|
cartes CarteEtudiante[]
|
||||||
|
|
||||||
@@map("utilisateur")
|
@@map("utilisateur")
|
||||||
}
|
}
|
||||||
@@ -86,3 +87,17 @@ model PosteEmprunt {
|
|||||||
|
|
||||||
@@map("poste_emprunt")
|
@@map("poste_emprunt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model CarteEtudiante {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
utilisateurId Int @map("utilisateur_id")
|
||||||
|
qrCode String @map("qr_code")
|
||||||
|
dateActivation DateTime @map("date_activation")
|
||||||
|
dateExpiration DateTime @map("date_expiration")
|
||||||
|
actif Boolean @default(true)
|
||||||
|
createdAt DateTime @default(now()) @map("created_at")
|
||||||
|
updatedAt DateTime @updatedAt @map("updated_at")
|
||||||
|
utilisateur Utilisateur @relation(fields: [utilisateurId], references: [id])
|
||||||
|
|
||||||
|
@@map("carte_etudiante")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user