initial commit, adding SQL connection and a simple testing on main
This commit is contained in:
1474
db/Models/assets/RBAC_model.svg
Normal file
1474
db/Models/assets/RBAC_model.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 159 KiB |
BIN
db/Models/model.mwb
Normal file
BIN
db/Models/model.mwb
Normal file
Binary file not shown.
55
db/Models/sql_generated/db_init.sql
Normal file
55
db/Models/sql_generated/db_init.sql
Normal file
@@ -0,0 +1,55 @@
|
||||
-- Creation of basic User Types
|
||||
INSERT INTO user_types (name, description) VALUES ('root','An easy way to identify the root user of the system');
|
||||
INSERT INTO user_types (name, description) VALUES ('company_owner','Company Owner');
|
||||
INSERT INTO user_types (name, description) VALUES ('company_manager','Company Level manager');
|
||||
INSERT INTO user_types (name, description) VALUES ('company_staff','Company Level Staff Memeber');
|
||||
INSERT INTO user_types (name, description) VALUES ('company_driver','Company Level Driver Member');
|
||||
INSERT INTO user_types (name, description) VALUES ('company_observer','Company Level Driver Member');
|
||||
|
||||
-- Creation of first user
|
||||
INSERT INTO users (user_type,name,last_name,created_at,updated_at) VALUES (1,'Pablo','Cruz',NOW(),NOW()); -- root -> root
|
||||
|
||||
-- Creation of basic roles
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("root","Root role with no restricted access",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("system_admin","System Level Admin",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("system_developer","System Level Developer",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("system_reader","System Level Read Only",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("system_staff","System Level staff member",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("company_owner","Unrestricted access to company resources",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("company_manager","Access as manager to company resources",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("company_staff","Access as staff to company resources",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("company_driver","Simple access to company resources",NOW(),NOW());
|
||||
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("company_observer","Limited access to company resources",NOW(),NOW());
|
||||
|
||||
-- Creation of basic permissions
|
||||
INSERT INTO permissions (name, description) VALUES ("root","Root role with no restricted access");
|
||||
INSERT INTO permissions (name, description) VALUES ("system.admin","System Level Admin");
|
||||
INSERT INTO permissions (name, description) VALUES ("system.developer","System Level Developer");
|
||||
INSERT INTO permissions (name, description) VALUES ("system.reader","System Level Reader");
|
||||
INSERT INTO permissions (name, description) VALUES ("system.staff","System Level Staff Member");
|
||||
INSERT INTO permissions (name, description) VALUES ("company.owner","Unrestricted access to company resources");
|
||||
INSERT INTO permissions (name, description) VALUES ("company.manager","Admin access to company resources");
|
||||
INSERT INTO permissions (name, description) VALUES ("company.staff","Staff access to company resources");
|
||||
INSERT INTO permissions (name, description) VALUES ("company.driver","Driver with simple access to company resources");
|
||||
INSERT INTO permissions (name, description) VALUES ("company.observer","Observer with simple access to company resources");
|
||||
|
||||
-- Link of basic roles with its permissions
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 1, 1 ); -- root -> root
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 2, 2 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 3, 3 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 4, 4 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 5, 5 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 6, 6 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 7, 7 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 8, 8 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 9, 9 );
|
||||
INSERT INTO role_permissions (role_id, permission_id) VALUES( 10, 10 );
|
||||
|
||||
-- Link of Root User with its role
|
||||
|
||||
INSERT INTO user_roles (user_id, role_id, created_at ) VALUES (1,1,NOW()); -- root -> root
|
||||
|
||||
-- Create Root Auth Identity and credentials
|
||||
|
||||
INSERT INTO auth_identities (user_id, provider, identifier, is_primary, is_verified, created_at, updated_at ) VALUES (1,"email","josepablo134@gmail.com",1,1,NOW(),NOW()); -- root access with email
|
||||
INSERT INTO auth_credentials (identity_id, password, created_at, updated_at) VALUES (1, "PasswordGoesHere", NOW(), NOW());
|
||||
174
db/Models/sql_generated/schema.sql
Normal file
174
db/Models/sql_generated/schema.sql
Normal file
@@ -0,0 +1,174 @@
|
||||
-- MySQL Script generated by MySQL Workbench
|
||||
-- Sun Dec 7 08:38:42 2025
|
||||
-- Model: New Model Version: 1.0
|
||||
-- MySQL Workbench Forward Engineering
|
||||
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema u947463964_etaviaporte
|
||||
-- -----------------------------------------------------
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Schema u947463964_etaviaporte
|
||||
-- -----------------------------------------------------
|
||||
CREATE SCHEMA IF NOT EXISTS `u947463964_etaviaporte` DEFAULT CHARACTER SET utf8 ;
|
||||
USE `u947463964_etaviaporte` ;
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`user_types`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`user_types` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`users`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`users` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user_type` INT UNSIGNED NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`last_name` TEXT NOT NULL,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_users_user_types1_idx` (`user_type` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_users_user_types1`
|
||||
FOREIGN KEY (`user_type`)
|
||||
REFERENCES `u947463964_etaviaporte`.`user_types` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`auth_identities`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`auth_identities` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`provider` TEXT NOT NULL,
|
||||
`identifier` TEXT NOT NULL COMMENT 'email, phone google, facebook, etc.',
|
||||
`is_primary` TINYINT NOT NULL DEFAULT 0,
|
||||
`is_verified` TINYINT NOT NULL DEFAULT 0,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
|
||||
INDEX `fk_auth_identities_users_idx` (`user_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_auth_identities_users`
|
||||
FOREIGN KEY (`user_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`users` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`auth_credentials`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`auth_credentials` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`identity_id` INT UNSIGNED NOT NULL,
|
||||
`password` TEXT NOT NULL,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
|
||||
INDEX `fk_auth_credentials_auth_identities1_idx` (`identity_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_auth_credentials_auth_identities1`
|
||||
FOREIGN KEY (`identity_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`auth_identities` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`roles`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`roles` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`permissions`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`permissions` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`description` TEXT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`role_permissions`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`role_permissions` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`role_id` INT UNSIGNED NOT NULL,
|
||||
`permission_id` INT UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
|
||||
INDEX `fk_role_permissions_roles1_idx` (`role_id` ASC) VISIBLE,
|
||||
INDEX `fk_role_permissions_permissions1_idx` (`permission_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_role_permissions_roles1`
|
||||
FOREIGN KEY (`role_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`roles` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_role_permissions_permissions1`
|
||||
FOREIGN KEY (`permission_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`permissions` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `u947463964_etaviaporte`.`user_roles`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `u947463964_etaviaporte`.`user_roles` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT UNSIGNED NOT NULL,
|
||||
`role_id` INT UNSIGNED NOT NULL,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`expires_at` DATETIME NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
|
||||
INDEX `fk_user_roles_users1_idx` (`user_id` ASC) VISIBLE,
|
||||
INDEX `fk_user_roles_roles1_idx` (`role_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_user_roles_users1`
|
||||
FOREIGN KEY (`user_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`users` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_user_roles_roles1`
|
||||
FOREIGN KEY (`role_id`)
|
||||
REFERENCES `u947463964_etaviaporte`.`roles` (`id`)
|
||||
ON DELETE CASCADE
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||
Reference in New Issue
Block a user