Projet

Général

Profil

US #769 » roles.sql

ahlem belgacem, 19/11/2024 22:12

 
1
use socle ;
2
-- Create the profile_role_permissions table with a foreign key reference to solution_menu
3
CREATE TABLE profile_role_permissions (
4
    id INT PRIMARY KEY AUTO_INCREMENT,    -- Auto-incremented primary key
5
    profileId INT,                        -- Foreign key to the profiles table
6
    moduleId INT,                         -- Foreign key to the Modules table
7
    canView BOOLEAN DEFAULT FALSE,        -- Permission to view
8
    canCreate BOOLEAN DEFAULT FALSE,      -- Permission to create
9
    canEdit BOOLEAN DEFAULT FALSE,        -- Permission to edit
10
    canImport BOOLEAN DEFAULT FALSE,      -- Permission to import
11
    canSearch BOOLEAN DEFAULT FALSE,      -- Permission to search
12
    canDelete BOOLEAN DEFAULT FALSE,      -- Permission to delete
13
	canDisable BOOLEAN DEFAULT FALSE,     -- Permission to disable
14
    FOREIGN KEY (profileId) REFERENCES company_profile(id),  -- Linking profileId to profiles table
15
    FOREIGN KEY (moduleId) REFERENCES solution_menu(id)     -- Linking moduleId to solution_menu table
16
);
17

    
18
INSERT INTO profile_role_permissions (profileId, moduleId, canView, canCreate, canEdit, canImport, canSearch, canDelete, canDisable)
19
VALUES
20
(1, 1, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE);  -- profile User can view, create, edit, import, search, delete, but cannot disable
21

    
22
INSERT INTO profile_role_permissions (profileId, moduleId, canView, canCreate, canEdit, canImport, canSearch, canDelete, canDisable)
23
VALUES
24
(2, 2, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE);  -- profile User  can view, create, edit, search, but cannot delete or disable
25

    
26
INSERT INTO profile_role_permissions (profileId, moduleId, canView, canCreate, canEdit, canImport, canSearch, canDelete, canDisable)
27
VALUES
28
(3, 3, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE);  -- profile User can view and search reports, but cannot create, edit, import, delete, or disable
(2-2/9)