Commit 8ef57f0d authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Corrections script de création de la bdd.

parent 5b8bb3f7
Pipeline #3558 failed with stages
in 2 minutes and 12 seconds
......@@ -70,7 +70,8 @@ CREATE INDEX idx_privilege_id on role_privilege(privilege_id);
-- Données
INSERT INTO user (username, email, display_name, password, state) VALUES
('admin', 'admin@mail.fr', 'Administrateur', '$2y$10$GmGzPXsLK5Kts30ZrS9QnOLsNYDgZ62797Kitp4Z1nWHlB1g7DZma', 1); -- password "admin"
-- utilisateur admin/azerty
('admin', 'admin@mail.fr', 'Administrateur', '$2y$10$QPbyqusyGOOuLlnRCmvZpuKDlAKorxtJJsjeW78bXnIKCFEE.bQiK', 1);
INSERT INTO user_role (id, role_id, is_default, parent_id) VALUES
(1, 'Standard', 1, NULL),
......@@ -92,3 +93,10 @@ INSERT INTO role_privilege (role_id, privilege_id) VALUES
(4, 2),
(4, 3),
(4, 4);
INSERT INTO user (username, email, display_name, password, state) VALUES
-- utilisateur demo/azerty
('demo', 'demo@mail.fr', 'Demo', '$2y$10$PxXnVLYnGEzEnfqPqRKJSe9AabocES2H4bBK5VzzJlzuj1rVt7Lwu', 1);
INSERT INTO user_role_linker(user_id, role_id)
SELECT u.id, r.id FROM user u, user_role r WHERE u.username = 'admin' and r.role_id = 'Standard';
......@@ -5,8 +5,8 @@ CREATE TABLE user (
display_name VARCHAR(64) DEFAULT NULL,
password VARCHAR(128) NOT NULL,
state SMALLINT default 1,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_username` (`username` ASC)
PRIMARY KEY (id),
UNIQUE INDEX unique_username (username ASC)
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
alter table user add PASSWORD_RESET_TOKEN varchar(256) default null;
......@@ -14,27 +14,27 @@ alter table user add PASSWORD_RESET_TOKEN varchar(256) default null;
create unique index USER_PASSWORD_RESET_TOKEN_UN on user (PASSWORD_RESET_TOKEN);
CREATE TABLE IF NOT EXISTS `user_role` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`role_id` VARCHAR(64) NOT NULL,
`is_default` TINYINT(1) NOT NULL DEFAULT 0,
`parent_id` INT(11) NULL DEFAULT NULL,
`ldap_filter` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `unique_role` (`role_id` ASC),
INDEX `idx_parent_id` (`parent_id` ASC),
CONSTRAINT `fk_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `user_role` (`id`) ON DELETE SET NULL
CREATE TABLE IF NOT EXISTS user_role (
id INT(11) NOT NULL AUTO_INCREMENT,
role_id VARCHAR(64) NOT NULL,
is_default TINYINT(1) NOT NULL DEFAULT 0,
parent_id INT(11) NULL DEFAULT NULL,
ldap_filter varchar(255) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE INDEX unique_role (role_id ASC),
INDEX idx_parent_id (parent_id ASC),
CONSTRAINT fk_parent_id FOREIGN KEY (parent_id) REFERENCES user_role (id) ON DELETE SET NULL
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `user_role_linker` (
`user_id` INT(11) NOT NULL,
`role_id` INT(11) NOT NULL,
PRIMARY KEY (`user_id`, `role_id`),
INDEX `idx_role_id` (`role_id` ASC),
INDEX `idx_user_id` (`user_id` ASC),
CONSTRAINT `fk_role_id` FOREIGN KEY (`role_id`) REFERENCES `user_role` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
CREATE TABLE IF NOT EXISTS user_role_linker (
user_id INT(11) NOT NULL,
role_id INT(11) NOT NULL,
PRIMARY KEY (user_id, role_id),
INDEX idx_role_id (role_id ASC),
INDEX idx_user_id (user_id ASC),
CONSTRAINT fk_role_id FOREIGN KEY (role_id) REFERENCES user_role (id) ON DELETE CASCADE,
CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
......@@ -72,23 +72,31 @@ CREATE TABLE IF NOT EXISTS role_privilege (
-- Données
INSERT INTO `user_role` (`id`, `role_id`, `is_default`, `parent_id`) VALUES
INSERT INTO user_role (id, role_id, is_default, parent_id) VALUES
(1, 'Standard', 1, NULL),
(2, 'Gestionnaire', 0, 1),
(3, 'Super-gestionnaire', 0, 2),
(4, 'Administrateur', 0, 3);
INSERT INTO `categorie_privilege` (`id`, `code`, `libelle`, `ordre`) VALUES
INSERT INTO categorie_privilege (id, code, libelle, ordre) VALUES
(1, 'droit', 'Gestion des droits', 1);
INSERT INTO `privilege` (`id`, `categorie_id`, `code`, `libelle`, `ordre`) VALUES
INSERT INTO privilege (id, categorie_id, code, libelle, ordre) VALUES
(1, 1, 'role-visualisation', 'Rôles - Visualisation', 1),
(2, 1, 'role-edition', 'Rôles - Édition', 2),
(3, 1, 'privilege-visualisation', 'Privilèges - Visualisation', 3),
(4, 1, 'privilege-edition', 'Privilèges - Édition', 4);
INSERT INTO `role_privilege` (`role_id`, `privilege_id`) VALUES
INSERT INTO role_privilege (role_id, privilege_id) VALUES
(4, 1),
(4, 2),
(4, 3),
(4, 4);
\ No newline at end of file
(4, 4);
INSERT INTO user (username, email, display_name, password, state) VALUES
-- utilisateur demo/azerty
('demo', 'demo@mail.fr', 'Demo', '$2y$10$PxXnVLYnGEzEnfqPqRKJSe9AabocES2H4bBK5VzzJlzuj1rVt7Lwu', 1);
INSERT INTO user_role_linker(user_id, role_id)
SELECT u.id, r.id FROM user u, user_role r WHERE u.username = 'admin' and r.role_id = 'Standard';
......@@ -53,6 +53,13 @@ INSERT INTO USER_ROLE (ID, ROLE_ID, IS_DEFAULT, PARENT_ID) VALUES (USER_ROLE_ID_
INSERT INTO USER_ROLE (ID, ROLE_ID, IS_DEFAULT, PARENT_ID) VALUES (USER_ROLE_ID_SEQ.NEXTVAL, 'Super-gestionnaire', 0, 2);
INSERT INTO USER_ROLE (ID, ROLE_ID, IS_DEFAULT, PARENT_ID) VALUES (USER_ROLE_ID_SEQ.NEXTVAL, 'Administrateur', 0, 3);
INSERT INTO "USER" (username, email, display_name, password, state) VALUES
-- utilisateur demo/azerty
('demo', 'demo@mail.fr', 'Demo', '$2y$10$PxXnVLYnGEzEnfqPqRKJSe9AabocES2H4bBK5VzzJlzuj1rVt7Lwu', 1);
INSERT INTO USER_ROLE_LINKER(user_id, role_id)
SELECT u.id, r.id FROM "USER" u, user_role r WHERE u.username = 'admin' and r.role_id = 'Standard';
/**
......
......@@ -65,6 +65,7 @@ CREATE UNIQUE INDEX role_privilege_unique ON role_privilege (role_id, privilege_
-- Données
INSERT INTO user_role (id, role_id, is_default, parent_id) VALUES
(1, 'Standard', 1, NULL),
(2, 'Gestionnaire', 0, 1),
......@@ -84,4 +85,11 @@ INSERT INTO role_privilege (role_id, privilege_id) VALUES
(4, 1),
(4, 2),
(4, 3),
(4, 4);
\ No newline at end of file
(4, 4);
INSERT INTO "user" (username, email, display_name, password, state) VALUES
-- utilisateur demo/azerty
('demo', 'demo@mail.fr', 'Demo', '$2y$10$PxXnVLYnGEzEnfqPqRKJSe9AabocES2H4bBK5VzzJlzuj1rVt7Lwu', 1);
INSERT INTO user_role_linker(user_id, role_id)
SELECT u.id, r.id FROM "user" u, user_role r WHERE u.username = 'admin' and r.role_id = 'Standard';
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment