-- 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 ('staff','Company Level Staff Memeber');
INSERT INTO user_types (name, description) VALUES ('driver','Company Level Driver Member');
INSERT INTO user_types (name, description) VALUES ('observer','Read Only 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 ("staff","Access as staff to company resources",NOW(),NOW());
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("driver","Simple access to company resources",NOW(),NOW());
INSERT INTO roles (name, description, created_at, updated_at) VALUES ("observer","Limited access to only read 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());
