-- Adminer 5.4.2 MS SQL  dump

DROP TABLE IF EXISTS [dbo].[_prisma_migrations];
CREATE TABLE [dbo].[_prisma_migrations] (
	[id] varchar(36) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[checksum] varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[finished_at] datetimeoffset NULL,
	[migration_name] nvarchar(250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[logs] nvarchar-05 COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[rolled_back_at] datetimeoffset NULL,
	[started_at] datetimeoffset NOT NULL DEFAULT '(getdate())',
	[applied_steps_count] int NOT NULL DEFAULT '((0))',
	CONSTRAINT [PK___prisma___3213E83F83C32F3A] PRIMARY KEY ([id])
);

INSERT INTO [dbo].[_prisma_migrations] ([id], [checksum], [finished_at], [migration_name], [logs], [rolled_back_at], [started_at], [applied_steps_count]) VALUES
('0f9bb926-166c-4082-8732-8a12e67b677d',	'c2faa7ef8d703d77e508f037850a7c2b07566b0eed00da21d85e1acfc5738a1e',	'Jun  4 2026 12:07:21:0885370PM',	'20260604120720_add_materiel_models',	NULL,	NULL,	'Jun  4 2026 12:07:21:0042228PM',	1),
('247934d2-3c7e-4798-a551-d3bdc81eb86d',	'fb4d09b02739fd6bf7cea5bfd0aad1bb0fbfcce21a04f1bd91ce300a4c8bbfec',	'Jun  5 2026 08:03:28:7441715AM',	'20260605080328_add_transaction_models',	NULL,	NULL,	'Jun  5 2026 08:03:28:6232902AM',	1),
('3266f9eb-7370-4b00-b749-f0ed39263d07',	'2e7b96c74202f25fd3ab0a9438fcc8699059fd5501d66092148daa41252f146b',	'Jun  4 2026 11:52:51:4456229AM',	'20260604115251_add_infrastructure_models',	NULL,	NULL,	'Jun  4 2026 11:52:51:3998600AM',	1),
('3cced054-eb44-41f8-89ac-51a72201310a',	'5e82403dcc57c7ab48dea2fe70e688714145f7f46b770a5c79ea868e6ba60f7a',	'Jun  4 2026 10:30:16:9084629AM',	'20260604103016_add_defaults_and_timestamps',	NULL,	NULL,	'Jun  4 2026 10:30:16:8610742AM',	1),
('3e9709da-458c-402d-8b32-bac51a84d241',	'c95d2b3e6c2454daa3fb9ba2ef7a99f9419e991174869612c81ab907e5a6d802',	'Jun  4 2026 12:02:27:3861796PM',	'20260604120227_add_carte_etudiante',	NULL,	NULL,	'Jun  4 2026 12:02:27:3195110PM',	1),
('5b298865-5e96-4b54-ad96-1ec3acc7080a',	'5e3e0d880e67c5ba91ccdb04f0dee6c056da6a325510c9dd9e4f9a80c5625fc4',	'Jun  4 2026 10:54:28:1304306AM',	'20260604125356_add_unique_constraints_and_nullable_classe',	NULL,	NULL,	'Jun  4 2026 10:54:28:0949933AM',	1),
('66581e38-0e42-435a-9937-06479116e595',	'4e632e5273ea555527c4726688865c7b21bc03d92df67e2f4679c6428d8a33e2',	'Jun  2 2026 02:19:19:8915005PM',	'20260602141919_init',	NULL,	NULL,	'Jun  2 2026 02:19:19:8389748PM',	1),
('fbf572ea-075e-4077-9d58-39fdf613d737',	'29faca22003505a071ea6b845d527566c51086c6b17980f386b70abff64d9148',	'Jun 15 2026 07:57:00:9671170AM',	'20260615075700_add_suivi_models',	NULL,	NULL,	'Jun 15 2026 07:57:00:8308160AM',	1);

DROP TABLE IF EXISTS [dbo].[accessoire];
CREATE TABLE [dbo].[accessoire] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[description] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[accessoire] ON;
INSERT INTO [dbo].[accessoire] ([id], [nom], [description], [actif], [created_at], [updated_at]) VALUES
(1,	'Chargeur',	'Chargeur secteur.',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(2,	'Souris',	'Souris filaire.',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(3,	'Housse',	'Housse de protection.',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(1002,	'Chargeur USB-C',	'Accessoire Chargeur USB-C.',	'1',	'2026-07-07 11:39:38',	'2026-07-07 11:39:38'),
(1003,	'Clavier Surface',	'Accessoire Clavier Surface.',	'1',	'2026-07-07 11:39:38',	'2026-07-07 11:39:38'),
(1004,	'Stylet',	'Accessoire Stylet.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1005,	'Telecommande',	'Accessoire Telecommande.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1006,	'Cable HDMI',	'Accessoire Cable HDMI.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1007,	'Batterie',	'Accessoire Batterie.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1008,	'Carte SD',	'Accessoire Carte SD.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1009,	'Adaptateur USB-C',	'Accessoire Adaptateur USB-C.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1010,	'Cable USB-C',	'Accessoire Cable USB-C.',	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39');
SET IDENTITY_INSERT [dbo].[accessoire] OFF;

DROP TABLE IF EXISTS [dbo].[anomalie];
CREATE TABLE [dbo].[anomalie] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[emprunt_id] int NOT NULL,
	[materiel_id] int NOT NULL,
	[utilisateur_id] int NOT NULL,
	[traitee_par_id] int NULL,
	[type] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[description] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[statut] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[detectee_automatiquement] bit NOT NULL DEFAULT '((1))',
	[observation] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[date_detection] datetime2 NOT NULL,
	[date_resolution] datetime2 NULL,
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[anomalie] ON;
INSERT INTO [dbo].[anomalie] ([id], [emprunt_id], [materiel_id], [utilisateur_id], [traitee_par_id], [type], [description], [statut], [detectee_automatiquement], [observation], [date_detection], [date_resolution], [created_at], [updated_at]) VALUES
(1,	4,	4,	3,	NULL,	'ACCESSOIRE_MANQUANT',	'Housse declaree presente au depart, absente au retour.',	'DETECTEE',	'1',	NULL,	'2026-06-14 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(2,	1002,	3,	1,	NULL,	'RETOUR_NON_CONFORME',	'Retour non conforme : Etat general manquant au retour.',	'DETECTEE',	'1',	NULL,	'2026-07-06 08:03:20',	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(1002,	4003,	1009,	2,	NULL,	'RETOUR_NON_CONFORME',	'Retour non conforme : Cable USB-C manquant au retour.',	'DETECTEE',	'1',	NULL,	'2026-07-08 09:19:47',	NULL,	'2026-07-08 09:19:47',	'2026-07-08 09:19:47');
SET IDENTITY_INSERT [dbo].[anomalie] OFF;

DROP TABLE IF EXISTS [dbo].[campus];
CREATE TABLE [dbo].[campus] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[adresse] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ville] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[code_postal] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[campus] ON;
INSERT INTO [dbo].[campus] ([id], [nom], [adresse], [ville], [code_postal], [actif], [created_at], [updated_at]) VALUES
(1,	'Campus Saint-Christophe',	'À compléter — Cergy Saint-Christophe',	'Cergy',	'95800',	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37');
SET IDENTITY_INSERT [dbo].[campus] OFF;

DROP TABLE IF EXISTS [dbo].[carte_etudiante];
CREATE TABLE [dbo].[carte_etudiante] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[utilisateur_id] int NOT NULL,
	[qr_code] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[date_activation] datetime2 NOT NULL,
	[date_expiration] datetime2 NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[carte_etudiante] ON;
INSERT INTO [dbo].[carte_etudiante] ([id], [utilisateur_id], [qr_code], [date_activation], [date_expiration], [actif], [created_at], [updated_at]) VALUES
(1,	1,	'QR-ETU-0001',	'2025-08-19 14:48:51',	'2027-07-20 14:48:51',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(2,	2,	'QR-ETU-0002',	'2025-08-19 14:48:51',	'2027-07-20 14:48:51',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(3,	3,	'QR-ETU-0003',	'2025-08-19 14:48:51',	'2027-07-20 14:48:51',	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52');
SET IDENTITY_INSERT [dbo].[carte_etudiante] OFF;

DROP TABLE IF EXISTS [dbo].[categorie_materiel];
CREATE TABLE [dbo].[categorie_materiel] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[description] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[categorie_materiel] ON;
INSERT INTO [dbo].[categorie_materiel] ([id], [nom], [description], [actif], [created_at], [updated_at]) VALUES
(1,	'Ordinateur portable',	'Ordinateurs portables pédagogiques.',	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37'),
(2,	'Vidéoprojecteur',	'Vidéoprojecteurs et accessoires de projection.',	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37'),
(3,	'Tablette',	'Tablettes tactiles.',	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37'),
(4,	'Caméra',	'Caméras et matériel de captation vidéo.',	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37'),
(5,	'Périphérique audio',	'Micros, casques et enceintes.',	'1',	'2026-06-15 09:03:38',	'2026-06-15 09:03:38'),
(6,	'Câble / Adaptateur',	'Câbles, adaptateurs et connectique.',	'1',	'2026-06-15 09:03:38',	'2026-06-15 09:03:38');
SET IDENTITY_INSERT [dbo].[categorie_materiel] OFF;

DROP TABLE IF EXISTS [dbo].[checklist];
CREATE TABLE [dbo].[checklist] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[emprunt_id] int NOT NULL,
	[utilisateur_id] int NOT NULL,
	[type] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[date_verification] datetime2 NOT NULL,
	[commentaire] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[checklist] ON;
INSERT INTO [dbo].[checklist] ([id], [emprunt_id], [utilisateur_id], [type], [date_verification], [commentaire], [created_at], [updated_at]) VALUES
(1,	1,	1,	'DEPART',	'2026-06-13 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(2,	2,	2,	'DEPART',	'2026-05-26 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(3,	3,	1,	'DEPART',	'2026-06-05 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(4,	3,	1,	'RETOUR',	'2026-06-12 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(5,	4,	3,	'DEPART',	'2026-06-10 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(6,	4,	3,	'RETOUR',	'2026-06-14 14:48:51',	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(1002,	1002,	1,	'DEPART',	'2026-07-06 07:38:13',	NULL,	'2026-07-06 07:38:13',	'2026-07-06 07:38:13'),
(1003,	1,	1,	'RETOUR',	'2026-07-06 08:03:20',	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(1004,	1002,	1,	'RETOUR',	'2026-07-06 08:03:20',	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(2002,	2002,	2,	'DEPART',	'2026-07-07 11:51:13',	NULL,	'2026-07-07 11:51:13',	'2026-07-07 11:51:13'),
(2003,	2003,	2,	'DEPART',	'2026-07-07 11:58:06',	NULL,	'2026-07-07 11:58:06',	'2026-07-07 11:58:06'),
(3002,	2,	2,	'RETOUR',	'2026-07-07 12:33:18',	NULL,	'2026-07-07 12:33:18',	'2026-07-07 12:33:18'),
(3003,	2002,	2,	'RETOUR',	'2026-07-07 12:33:29',	NULL,	'2026-07-07 12:33:29',	'2026-07-07 12:33:29'),
(3004,	2003,	2,	'RETOUR',	'2026-07-07 12:33:43',	NULL,	'2026-07-07 12:33:43',	'2026-07-07 12:33:43'),
(3005,	3002,	2,	'DEPART',	'2026-07-07 12:34:25',	NULL,	'2026-07-07 12:34:25',	'2026-07-07 12:34:25'),
(4002,	4002,	2,	'DEPART',	'2026-07-08 09:19:17',	NULL,	'2026-07-08 09:19:17',	'2026-07-08 09:19:17'),
(4003,	4002,	2,	'RETOUR',	'2026-07-08 09:19:17',	NULL,	'2026-07-08 09:19:17',	'2026-07-08 09:19:17'),
(4004,	4003,	2,	'DEPART',	'2026-07-08 09:19:47',	NULL,	'2026-07-08 09:19:47',	'2026-07-08 09:19:47'),
(4005,	4003,	2,	'RETOUR',	'2026-07-08 09:19:47',	NULL,	'2026-07-08 09:19:47',	'2026-07-08 09:19:47'),
(4006,	4004,	2,	'DEPART',	'2026-07-08 13:19:04',	NULL,	'2026-07-08 13:19:04',	'2026-07-08 13:19:04');
SET IDENTITY_INSERT [dbo].[checklist] OFF;

DROP TABLE IF EXISTS [dbo].[checklist_element];
CREATE TABLE [dbo].[checklist_element] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[checklist_id] int NOT NULL,
	[accessoire_id] int NULL,
	[nom_element] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[etat] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[quantite_constatee] int NOT NULL,
	[commentaire] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[checklist_element] ON;
INSERT INTO [dbo].[checklist_element] ([id], [checklist_id], [accessoire_id], [nom_element], [etat], [quantite_constatee], [commentaire], [created_at], [updated_at]) VALUES
(1,	1,	1,	'Chargeur',	'PRESENT',	1,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(2,	1,	2,	'Souris',	'PRESENT',	1,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(3,	5,	3,	'Housse',	'PRESENT',	1,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(4,	5,	1,	'Chargeur',	'PRESENT',	1,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(5,	6,	3,	'Housse',	'ABSENT',	0,	'Manquante au retour',	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(6,	6,	1,	'Chargeur',	'PRESENT',	1,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(1002,	1002,	NULL,	'Etat general',	'PRESENT',	1,	NULL,	'2026-07-06 07:38:13',	'2026-07-06 07:38:13'),
(1003,	1003,	NULL,	'Chargeur',	'PRESENT',	1,	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(1004,	1003,	NULL,	'Souris',	'PRESENT',	1,	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(1005,	1004,	NULL,	'Etat general',	'ABSENT',	0,	NULL,	'2026-07-06 08:03:20',	'2026-07-06 08:03:20'),
(2002,	2002,	NULL,	'Batterie',	'ABSENT',	0,	NULL,	'2026-07-07 11:51:13',	'2026-07-07 11:51:13'),
(2003,	2002,	NULL,	'Carte SD',	'PRESENT',	1,	NULL,	'2026-07-07 11:51:13',	'2026-07-07 11:51:13'),
(2004,	2002,	NULL,	'Housse',	'PRESENT',	1,	NULL,	'2026-07-07 11:51:13',	'2026-07-07 11:51:13'),
(2005,	2003,	NULL,	'Chargeur USB-C',	'ABSENT',	0,	NULL,	'2026-07-07 11:58:06',	'2026-07-07 11:58:06'),
(2006,	2003,	NULL,	'Housse',	'PRESENT',	1,	NULL,	'2026-07-07 11:58:06',	'2026-07-07 11:58:06'),
(3002,	3002,	NULL,	'Vidéoprojecteur Epson',	'PRESENT',	1,	NULL,	'2026-07-07 12:33:18',	'2026-07-07 12:33:18'),
(3003,	3003,	NULL,	'Batterie',	'PRESENT',	1,	NULL,	'2026-07-07 12:33:29',	'2026-07-07 12:33:29'),
(3004,	3003,	NULL,	'Carte SD',	'PRESENT',	1,	NULL,	'2026-07-07 12:33:29',	'2026-07-07 12:33:29'),
(3005,	3003,	NULL,	'Housse',	'PRESENT',	1,	NULL,	'2026-07-07 12:33:29',	'2026-07-07 12:33:29'),
(3006,	3004,	NULL,	'Chargeur USB-C',	'ABSENT',	0,	NULL,	'2026-07-07 12:33:43',	'2026-07-07 12:33:43'),
(3007,	3004,	NULL,	'Housse',	'PRESENT',	1,	NULL,	'2026-07-07 12:33:43',	'2026-07-07 12:33:43'),
(3008,	3005,	NULL,	'Chargeur',	'PRESENT',	1,	NULL,	'2026-07-07 12:34:25',	'2026-07-07 12:34:25'),
(3009,	3005,	NULL,	'Housse',	'ABSENT',	0,	NULL,	'2026-07-07 12:34:25',	'2026-07-07 12:34:25'),
(3010,	3005,	NULL,	'Souris',	'PRESENT',	1,	NULL,	'2026-07-07 12:34:25',	'2026-07-07 12:34:25'),
(4002,	4002,	NULL,	'Casque Jabra Evolve',	'PRESENT',	1,	NULL,	'2026-07-08 09:19:17',	'2026-07-08 09:19:17'),
(4003,	4003,	NULL,	'Casque Jabra Evolve',	'PRESENT',	1,	NULL,	'2026-07-08 09:19:17',	'2026-07-08 09:19:17'),
(4004,	4004,	NULL,	'Cable USB-C',	'PRESENT',	1,	NULL,	'2026-07-08 09:19:47',	'2026-07-08 09:19:47'),
(4005,	4005,	NULL,	'Cable USB-C',	'ABSENT',	0,	NULL,	'2026-07-08 09:19:47',	'2026-07-08 09:19:47'),
(4006,	4006,	NULL,	'Chargeur USB-C',	'ABSENT',	0,	NULL,	'2026-07-08 13:19:04',	'2026-07-08 13:19:04'),
(4007,	4006,	NULL,	'Housse',	'PRESENT',	1,	NULL,	'2026-07-08 13:19:04',	'2026-07-08 13:19:04');
SET IDENTITY_INSERT [dbo].[checklist_element] OFF;

DROP TABLE IF EXISTS [dbo].[emprunt];
CREATE TABLE [dbo].[emprunt] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[utilisateur_id] int NOT NULL,
	[materiel_id] int NOT NULL,
	[campus_id] int NOT NULL,
	[salle_pret_id] int NOT NULL,
	[poste_emprunt_id] int NOT NULL,
	[date_emprunt] datetime2 NOT NULL,
	[date_retour_prevue] datetime2 NOT NULL,
	[date_retour_reelle] datetime2 NULL,
	[statut] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[mode_identification_emprunt] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[mode_identification_retour] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[commentaire_depart] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[commentaire_retour] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[emprunt] ON;
INSERT INTO [dbo].[emprunt] ([id], [utilisateur_id], [materiel_id], [campus_id], [salle_pret_id], [poste_emprunt_id], [date_emprunt], [date_retour_prevue], [date_retour_reelle], [statut], [mode_identification_emprunt], [mode_identification_retour], [commentaire_depart], [commentaire_retour], [created_at], [updated_at]) VALUES
(1,	1,	1,	1,	1,	1,	'2026-06-13 14:48:51',	'2026-06-20 14:48:51',	'2026-07-06 08:03:20',	'CLOTURE',	'QR_CODE',	'QR_CODE',	NULL,	NULL,	'2026-06-15 14:48:53',	'2026-07-06 08:03:20'),
(2,	2,	2,	1,	1,	1,	'2026-05-26 14:48:51',	'2026-06-09 14:48:51',	'2026-07-07 12:33:18',	'CLOTURE',	'MAIL_ENSUP',	'MAIL_ENSUP',	NULL,	NULL,	'2026-06-15 14:48:53',	'2026-07-07 12:33:18'),
(3,	1,	3,	1,	1,	1,	'2026-06-05 14:48:51',	'2026-06-12 14:48:51',	'2026-06-12 14:48:51',	'CLOTURE',	'QR_CODE',	'QR_CODE',	NULL,	NULL,	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(4,	3,	4,	1,	1,	1,	'2026-06-10 14:48:51',	'2026-06-14 14:48:51',	'2026-06-14 14:48:51',	'RETOUR_NON_CONFORME',	'MAIL_ENSUP',	'MAIL_ENSUP',	NULL,	'Housse non rapportee.',	'2026-06-15 14:48:53',	'2026-06-15 14:48:53'),
(1002,	1,	3,	1,	1,	1,	'2026-07-06 07:38:13',	'2026-07-20 07:38:13',	'2026-07-06 08:03:20',	'RETOUR_NON_CONFORME',	'QR_CODE',	'QR_CODE',	'RAS',	'element manquant',	'2026-07-06 07:38:13',	'2026-07-06 08:03:20'),
(2002,	2,	1006,	1,	1,	1,	'2026-07-07 11:51:13',	'2026-07-21 11:51:13',	'2026-07-07 12:33:29',	'CLOTURE',	'MAIL_ENSUP',	'MAIL_ENSUP',	NULL,	NULL,	'2026-07-07 11:51:13',	'2026-07-07 12:33:29'),
(2003,	2,	1003,	1,	1,	1,	'2026-07-07 11:58:06',	'2026-07-21 11:58:06',	'2026-07-07 12:33:43',	'CLOTURE',	'MAIL_ENSUP',	'MAIL_ENSUP',	NULL,	NULL,	'2026-07-07 11:58:06',	'2026-07-07 12:33:44'),
(3002,	2,	1002,	1,	1,	1,	'2026-07-07 12:34:25',	'2026-07-21 12:34:25',	NULL,	'EN_COURS',	'MAIL_ENSUP',	NULL,	NULL,	NULL,	'2026-07-07 12:34:25',	'2026-07-07 12:34:25'),
(4002,	2,	1007,	1,	1,	1,	'2026-07-08 09:19:17',	'2026-07-22 09:19:17',	'2026-07-08 09:19:17',	'CLOTURE',	'MAIL_ENSUP',	'MAIL_ENSUP',	'Test stabilisation API',	'Retour test conforme',	'2026-07-08 09:19:17',	'2026-07-08 09:19:17'),
(4003,	2,	1009,	1,	1,	1,	'2026-07-08 09:19:47',	'2026-07-22 09:19:46',	'2026-07-08 09:19:47',	'RETOUR_NON_CONFORME',	'MAIL_ENSUP',	'MAIL_ENSUP',	'Test non conforme API',	'Retour test non conforme',	'2026-07-08 09:19:47',	'2026-07-08 09:19:47'),
(4004,	2,	1003,	1,	1,	1,	'2026-07-08 13:19:04',	'2026-07-22 13:19:04',	NULL,	'EN_COURS',	'MAIL_ENSUP',	NULL,	NULL,	NULL,	'2026-07-08 13:19:04',	'2026-07-08 13:19:04');
SET IDENTITY_INSERT [dbo].[emprunt] OFF;

DROP TABLE IF EXISTS [dbo].[historique];
CREATE TABLE [dbo].[historique] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[utilisateur_id] int NOT NULL,
	[emprunt_id] int NULL,
	[materiel_id] int NULL,
	[campus_id] int NULL,
	[salle_pret_id] int NULL,
	[poste_emprunt_id] int NULL,
	[action] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[description] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[date_action] datetime2 NOT NULL,
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())'
);

SET IDENTITY_INSERT [dbo].[historique] ON;
INSERT INTO [dbo].[historique] ([id], [utilisateur_id], [emprunt_id], [materiel_id], [campus_id], [salle_pret_id], [poste_emprunt_id], [action], [description], [date_action], [created_at]) VALUES
(1,	1,	1,	1,	1,	1,	1,	'CREATION_EMPRUNT',	'Emprunt du PC portable Dell.',	'2026-06-13 14:48:51',	'2026-06-15 14:48:53'),
(2,	3,	4,	4,	1,	1,	1,	'CREATION_ANOMALIE',	'Anomalie detectee au retour de la Caméra Sony.',	'2026-06-14 14:48:51',	'2026-06-15 14:48:53');
SET IDENTITY_INSERT [dbo].[historique] OFF;

DROP TABLE IF EXISTS [dbo].[materiel];
CREATE TABLE [dbo].[materiel] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[marque] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[modele] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[reference] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[numero_inventaire] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[numero_serie] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[statut] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[etat_general] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[categorie_id] int NOT NULL,
	[campus_id] int NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[materiel] ON;
INSERT INTO [dbo].[materiel] ([id], [nom], [marque], [modele], [reference], [numero_inventaire], [numero_serie], [statut], [etat_general], [categorie_id], [campus_id], [actif], [created_at], [updated_at]) VALUES
(1,	'PC portable Dell Latitude',	'Dell',	'Latitude 5440',	'REF-PC-001',	'INV-PC-001',	'SN-DELL-001',	'DISPONIBLE',	'Bon etat',	1,	1,	'1',	'2026-06-15 14:48:52',	'2026-07-06 08:03:20'),
(2,	'Vidéoprojecteur Epson',	'Epson',	'EB-W06',	'REF-VP-001',	'INV-VP-001',	'SN-EPSON-001',	'DISPONIBLE',	'Bon etat',	2,	1,	'1',	'2026-06-15 14:48:52',	'2026-07-07 12:33:18'),
(3,	'Tablette iPad',	'Apple',	'iPad 10',	'REF-TAB-001',	'INV-TAB-001',	'SN-IPAD-001',	'NON_CONFORME',	'Bon etat',	3,	1,	'1',	'2026-06-15 14:48:52',	'2026-07-06 08:03:20'),
(4,	'Caméra Sony',	'Sony',	'Alpha 6400',	'REF-CAM-001',	'INV-CAM-001',	'SN-SONY-001',	'DETERIORE',	'Housse manquante au retour',	4,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(5,	'Micro Rode',	'Rode',	'NT-USB',	'REF-MIC-001',	'INV-MIC-001',	'SN-RODE-001',	'DISPONIBLE',	'Bon etat',	5,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(6,	'PC portable HP',	'HP',	'ProBook 450',	'REF-PC-002',	'INV-PC-002',	'SN-HP-002',	'MAINTENANCE',	'En revision',	1,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(1002,	'PC Lenovo ThinkPad E14',	'Lenovo',	'ThinkPad E14',	'REF-PC-003',	'INV-PC-003',	'SN-LENOVO-003',	'EMPRUNTE',	'Bon etat',	1,	1,	'1',	'2026-07-07 11:39:38',	'2026-07-07 12:34:25'),
(1003,	'MacBook Air M2',	'Apple',	'MacBook Air 13',	'REF-PC-004',	'INV-PC-004',	'SN-MBA-004',	'EMPRUNTE',	'Tres bon etat',	1,	1,	'1',	'2026-07-07 11:39:38',	'2026-07-08 13:19:04'),
(1004,	'Microsoft Surface Pro',	'Microsoft',	'Surface Pro 9',	'REF-TAB-002',	'INV-TAB-002',	'SN-SURFACE-002',	'DISPONIBLE',	'Bon etat',	3,	1,	'1',	'2026-07-07 11:39:38',	'2026-07-07 11:39:38'),
(1005,	'Vidéoprojecteur Epson EB-X49',	'Epson',	'EB-X49',	'REF-VP-002',	'INV-VP-002',	'SN-EPSON-002',	'DISPONIBLE',	'Bon etat',	2,	1,	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1006,	'Caméra Canon EOS M50',	'Canon',	'EOS M50',	'REF-CAM-002',	'INV-CAM-002',	'SN-CANON-002',	'DISPONIBLE',	'Bon etat',	4,	1,	'1',	'2026-07-07 11:39:39',	'2026-07-07 12:33:29'),
(1007,	'Casque Jabra Evolve',	'Jabra',	'Evolve 40',	'REF-AUD-002',	'INV-AUD-002',	'SN-JABRA-002',	'DISPONIBLE',	'Bon etat',	5,	1,	'1',	'2026-07-07 11:39:39',	'2026-07-08 09:19:17'),
(1008,	'Kit câbles HDMI / USB-C',	'ENSUP',	'Kit connectique',	'REF-CAB-001',	'INV-CAB-001',	'SN-CABLE-001',	'DISPONIBLE',	'Bon etat',	6,	1,	'1',	'2026-07-07 11:39:39',	'2026-07-07 11:39:39'),
(1009,	'Enceinte Bluetooth JBL',	'JBL',	'Flip 6',	'REF-AUD-003',	'INV-AUD-003',	'SN-JBL-003',	'NON_CONFORME',	'Bon etat',	5,	1,	'1',	'2026-07-07 11:39:39',	'2026-07-08 09:19:47');
SET IDENTITY_INSERT [dbo].[materiel] OFF;

DROP TABLE IF EXISTS [dbo].[materiel_accessoire];
CREATE TABLE [dbo].[materiel_accessoire] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[materiel_id] int NOT NULL,
	[accessoire_id] int NOT NULL,
	[quantite_attendue] int NOT NULL,
	[obligatoire] bit NOT NULL
);

SET IDENTITY_INSERT [dbo].[materiel_accessoire] ON;
INSERT INTO [dbo].[materiel_accessoire] ([id], [materiel_id], [accessoire_id], [quantite_attendue], [obligatoire]) VALUES
(1,	1,	1,	1,	'1'),
(2,	1,	2,	1,	'0'),
(3,	4,	3,	1,	'1'),
(4,	4,	1,	1,	'1'),
(1002,	1002,	1,	1,	'1'),
(1003,	1002,	2,	1,	'1'),
(1004,	1002,	3,	1,	'1'),
(1005,	1003,	1002,	1,	'1'),
(1006,	1003,	3,	1,	'1'),
(1007,	1004,	1003,	1,	'1'),
(1008,	1004,	1004,	1,	'1'),
(1009,	1005,	1005,	1,	'1'),
(1010,	1005,	1006,	1,	'1'),
(1011,	1006,	1007,	1,	'1'),
(1012,	1006,	1008,	1,	'1'),
(1013,	1006,	3,	1,	'1'),
(1014,	1008,	1006,	1,	'1'),
(1015,	1008,	1009,	1,	'1'),
(1016,	1009,	1010,	1,	'1');
SET IDENTITY_INSERT [dbo].[materiel_accessoire] OFF;

DROP TABLE IF EXISTS [dbo].[notification];
CREATE TABLE [dbo].[notification] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[utilisateur_id] int NOT NULL,
	[anomalie_id] int NULL,
	[titre] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[message] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[type] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[lu] bit NOT NULL DEFAULT '((0))',
	[date_creation] datetime2 NOT NULL DEFAULT '(getdate())'
);

SET IDENTITY_INSERT [dbo].[notification] ON;
INSERT INTO [dbo].[notification] ([id], [utilisateur_id], [anomalie_id], [titre], [message], [type], [lu], [date_creation]) VALUES
(1,	4,	1,	'Nouvelle anomalie detectee',	'Retour non conforme sur la Caméra Sony (housse manquante).',	'ANOMALIE',	'0',	'2026-06-15 14:48:53'),
(2,	4,	2,	'Nouvelle anomalie detectee',	'Retour non conforme : Etat general manquant au retour.',	'ANOMALIE',	'0',	'2026-07-06 08:03:20'),
(1002,	4,	1002,	'Nouvelle anomalie detectee',	'Retour non conforme : Cable USB-C manquant au retour.',	'ANOMALIE',	'0',	'2026-07-08 09:19:47');
SET IDENTITY_INSERT [dbo].[notification] OFF;

DROP TABLE IF EXISTS [dbo].[poste_emprunt];
CREATE TABLE [dbo].[poste_emprunt] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[identifiant_poste] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[salle_pret_id] int NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[poste_emprunt] ON;
INSERT INTO [dbo].[poste_emprunt] ([id], [nom], [identifiant_poste], [salle_pret_id], [actif], [created_at], [updated_at]) VALUES
(1,	'Poste 1',	'POSTE-01',	1,	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37');
SET IDENTITY_INSERT [dbo].[poste_emprunt] OFF;

DROP TABLE IF EXISTS [dbo].[role];
CREATE TABLE [dbo].[role] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[code] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[libelle] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[description] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	CONSTRAINT [role_code_key] UNIQUE ([code])
);

SET IDENTITY_INSERT [dbo].[role] ON;
INSERT INTO [dbo].[role] ([id], [code], [libelle], [description]) VALUES
(1,	'ETUDIANT',	'Étudiant',	'Emprunte et restitue du matériel via le poste dédié.'),
(2,	'RESPONSABLE',	'Responsable matériel',	'Supervise, gère le stock et traite les anomalies.');
SET IDENTITY_INSERT [dbo].[role] OFF;

DROP TABLE IF EXISTS [dbo].[salle_pret];
CREATE TABLE [dbo].[salle_pret] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[localisation] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[campus_id] int NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL
);

SET IDENTITY_INSERT [dbo].[salle_pret] ON;
INSERT INTO [dbo].[salle_pret] ([id], [nom], [localisation], [campus_id], [actif], [created_at], [updated_at]) VALUES
(1,	'Salle de prêt principale',	'Campus Saint-Christophe',	1,	'1',	'2026-06-15 09:03:37',	'2026-06-15 09:03:37');
SET IDENTITY_INSERT [dbo].[salle_pret] OFF;

DROP TABLE IF EXISTS [dbo].[utilisateur];
CREATE TABLE [dbo].[utilisateur] (
	[id] int NOT NULL IDENTITY PRIMARY KEY,
	[microsoft_id] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[nom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[prenom] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[email] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[classe] nvarchar(1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[role_id] int NOT NULL,
	[campus_id] int NOT NULL,
	[actif] bit NOT NULL DEFAULT '((1))',
	[created_at] datetime2 NOT NULL DEFAULT '(getdate())',
	[updated_at] datetime2 NOT NULL,
	CONSTRAINT [utilisateur_microsoft_id_key] UNIQUE ([microsoft_id]),
	CONSTRAINT [utilisateur_email_key] UNIQUE ([email])
);

SET IDENTITY_INSERT [dbo].[utilisateur] ON;
INSERT INTO [dbo].[utilisateur] ([id], [microsoft_id], [nom], [prenom], [email], [classe], [role_id], [campus_id], [actif], [created_at], [updated_at]) VALUES
(1,	'ms-marie-dupont',	'Dupont',	'Marie',	'marie.dupont@ensitech.eu',	'B3 Informatique',	1,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(2,	'ms-lucas-martin',	'Martin',	'Lucas',	'lucas.martin@ensitech.eu',	'B2 Informatique',	1,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(3,	'ms-sofia-bernard',	'Bernard',	'Sofia',	'sofia.bernard@ensup.eu',	'B1 Marketing',	1,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52'),
(4,	'ms-karim-benali',	'Benali',	'Karim',	'karim.benali@ensup.eu',	NULL,	2,	1,	'1',	'2026-06-15 14:48:52',	'2026-06-15 14:48:52');
SET IDENTITY_INSERT [dbo].[utilisateur] OFF;

ALTER TABLE [dbo].[anomalie] ADD
	FOREIGN KEY ([emprunt_id]) REFERENCES [emprunt] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([materiel_id]) REFERENCES [materiel] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([traitee_par_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[carte_etudiante] ADD
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE [dbo].[checklist] ADD
	FOREIGN KEY ([emprunt_id]) REFERENCES [emprunt] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[checklist_element] ADD
	FOREIGN KEY ([accessoire_id]) REFERENCES [accessoire] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([checklist_id]) REFERENCES [checklist] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[emprunt] ADD
	FOREIGN KEY ([campus_id]) REFERENCES [campus] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([materiel_id]) REFERENCES [materiel] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([poste_emprunt_id]) REFERENCES [poste_emprunt] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([salle_pret_id]) REFERENCES [salle_pret] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[historique] ADD
	FOREIGN KEY ([campus_id]) REFERENCES [campus] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([emprunt_id]) REFERENCES [emprunt] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([materiel_id]) REFERENCES [materiel] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([poste_emprunt_id]) REFERENCES [poste_emprunt] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([salle_pret_id]) REFERENCES [salle_pret] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[materiel] ADD
	FOREIGN KEY ([campus_id]) REFERENCES [campus] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE,
	FOREIGN KEY ([categorie_id]) REFERENCES [categorie_materiel] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE [dbo].[materiel_accessoire] ADD
	FOREIGN KEY ([accessoire_id]) REFERENCES [accessoire] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE,
	FOREIGN KEY ([materiel_id]) REFERENCES [materiel] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE [dbo].[notification] ADD
	FOREIGN KEY ([anomalie_id]) REFERENCES [anomalie] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION,
	FOREIGN KEY ([utilisateur_id]) REFERENCES [utilisateur] ([id]) ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE [dbo].[poste_emprunt] ADD
	FOREIGN KEY ([salle_pret_id]) REFERENCES [salle_pret] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE [dbo].[salle_pret] ADD
	FOREIGN KEY ([campus_id]) REFERENCES [campus] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE [dbo].[utilisateur] ADD
	FOREIGN KEY ([campus_id]) REFERENCES [campus] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE,
	FOREIGN KEY ([role_id]) REFERENCES [role] ([id]) ON DELETE NO ACTION ON UPDATE CASCADE;

-- 2026-07-10 09:04:02 UTC
