Files
ms1inscription-v5/sql/MSIN-eve-acces-v2-phase1-tables.sql
stephan 6403f371fe Enhance batch and auto selection UI with new prompts and visibility logic; increment version code to 4.72.688
This commit introduces a new prompt for sequence selection in batch and auto modes, improving user guidance. The visibility logic for various action groups is refined based on selection states, ensuring a clearer interface. Additionally, CSS styles are updated to support the new prompt, enhancing the overall user experience in the bib management system.
2026-06-19 11:43:57 -04:00

162 lines
5.7 KiB
SQL

/*
MSIN - Acces evenement v2 (phase 1)
Tables NEUVES uniquement. Aucune modification des tables legacy.
Legacy inchange :
inscriptions_comptes.com_eve_promoteur
inscriptions_comptes.com_rapports
inscriptions_comptes.com_eve_modifiable
Ordre :
1) Ce fichier
2) MSIN-eve-acces-v2-phase1-seed.sql
*/
SET NAMES utf8mb4;
/* 1. Catalogue des permissions */
CREATE TABLE IF NOT EXISTS `inscriptions_eve_permissions` (
`perm_key` varchar(64) NOT NULL,
`perm_group` varchar(32) NOT NULL DEFAULT 'general',
`perm_label_fr` varchar(100) NOT NULL,
`perm_label_en` varchar(100) NOT NULL,
`perm_description_fr` varchar(255) DEFAULT NULL,
`perm_description_en` varchar(255) DEFAULT NULL,
`perm_phase` tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '1=mobile API, 2=web promoteur, 3=rapports',
`perm_actif` tinyint(1) unsigned NOT NULL DEFAULT 1,
`perm_tri` smallint(5) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY (`perm_key`),
KEY `idx_perm_group` (`perm_group`, `perm_actif`, `perm_tri`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Catalogue permissions v2';
/* 2. Roles (super admin seulement) */
CREATE TABLE IF NOT EXISTS `inscriptions_eve_roles` (
`role_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`role_code` varchar(32) NOT NULL,
`role_label_fr` varchar(80) NOT NULL,
`role_label_en` varchar(80) NOT NULL,
`role_description_fr` varchar(255) DEFAULT NULL,
`role_description_en` varchar(255) DEFAULT NULL,
`role_icone` varchar(32) DEFAULT NULL,
`role_systeme` tinyint(1) unsigned NOT NULL DEFAULT 1,
`role_actif` tinyint(1) unsigned NOT NULL DEFAULT 1,
`role_tri` smallint(5) unsigned NOT NULL DEFAULT 0,
`role_created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`role_updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`role_id`),
UNIQUE KEY `uk_role_code` (`role_code`),
KEY `idx_role_actif` (`role_actif`, `role_tri`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Roles v2';
/* 3. Permissions par role */
CREATE TABLE IF NOT EXISTS `inscriptions_eve_role_permissions` (
`role_id` int(10) unsigned NOT NULL,
`perm_key` varchar(64) NOT NULL,
PRIMARY KEY (`role_id`, `perm_key`),
KEY `idx_erp_perm` (`perm_key`),
CONSTRAINT `fk_erp_role`
FOREIGN KEY (`role_id`) REFERENCES `inscriptions_eve_roles` (`role_id`)
ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_erp_perm`
FOREIGN KEY (`perm_key`) REFERENCES `inscriptions_eve_permissions` (`perm_key`)
ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Matrice role-permission';
/* 4. Assignations compte x evenement */
CREATE TABLE IF NOT EXISTS `inscriptions_eve_acces` (
`ea_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`com_id` int(10) unsigned NOT NULL,
`eve_id` int(10) unsigned NOT NULL,
`role_id` int(10) unsigned NOT NULL,
`ea_statut` enum('actif','revoke','invite') NOT NULL DEFAULT 'actif',
`ea_expires_at` datetime DEFAULT NULL,
`ea_expire_days` smallint(5) unsigned DEFAULT NULL,
`ea_granted_by` int(10) unsigned DEFAULT NULL,
`ea_note` varchar(255) DEFAULT NULL,
`ea_created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ea_updated_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`ea_revoked_at` datetime DEFAULT NULL,
`ea_revoked_by` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`ea_id`),
UNIQUE KEY `uk_com_eve` (`com_id`, `eve_id`),
KEY `idx_eve_actif` (`eve_id`, `ea_statut`),
KEY `idx_com_actif` (`com_id`, `ea_statut`),
KEY `idx_expires` (`ea_expires_at`, `ea_statut`),
KEY `idx_role` (`role_id`),
CONSTRAINT `fk_ea_role`
FOREIGN KEY (`role_id`) REFERENCES `inscriptions_eve_roles` (`role_id`)
ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Acces v2 par compte et evenement';
/* 5. Journal audit */
CREATE TABLE IF NOT EXISTS `inscriptions_eve_acces_log` (
`log_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`ea_id` int(10) unsigned DEFAULT NULL,
`com_id` int(10) unsigned NOT NULL,
`eve_id` int(10) unsigned NOT NULL,
`role_id` int(10) unsigned DEFAULT NULL,
`log_action` varchar(32) NOT NULL,
`log_detail` text DEFAULT NULL,
`log_by_com_id` int(10) unsigned DEFAULT NULL,
`log_created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`log_id`),
KEY `idx_log_eve` (`eve_id`, `log_created_at`),
KEY `idx_log_com` (`com_id`, `log_created_at`),
KEY `idx_log_ea` (`ea_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Audit acces v2';
/* 6. Vue acces actifs */
DROP VIEW IF EXISTS `v_eve_acces_actif`;
CREATE VIEW `v_eve_acces_actif` AS
SELECT
ea.ea_id,
ea.com_id,
ea.eve_id,
ea.role_id,
r.role_code,
r.role_label_fr,
r.role_label_en,
ea.ea_statut,
ea.ea_expires_at,
ea.ea_expire_days,
ea.ea_granted_by,
ea.ea_created_at
FROM inscriptions_eve_acces ea
INNER JOIN inscriptions_eve_roles r
ON r.role_id = ea.role_id
AND r.role_actif = 1
WHERE ea.ea_statut = 'actif'
AND (ea.ea_expires_at IS NULL OR ea.ea_expires_at > NOW());
/* 7. Vue permissions effectives */
DROP VIEW IF EXISTS `v_eve_acces_permissions`;
CREATE VIEW `v_eve_acces_permissions` AS
SELECT
v.ea_id,
v.com_id,
v.eve_id,
v.role_id,
v.role_code,
erp.perm_key,
p.perm_group,
p.perm_label_fr,
p.perm_phase
FROM v_eve_acces_actif v
INNER JOIN inscriptions_eve_role_permissions erp
ON erp.role_id = v.role_id
INNER JOIN inscriptions_eve_permissions p
ON p.perm_key = erp.perm_key
AND p.perm_actif = 1;