feat(db): add CarteEtudiante model

This commit is contained in:
SaidSoighiri94
2026-06-04 14:03:32 +02:00
parent d026b75372
commit dfa73cdab0
2 changed files with 49 additions and 2 deletions
@@ -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