mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 02:57:36 +00:00
Database updates
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Delete`(IN p_id_goal CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM goal
|
||||||
|
WHERE id_goal = p_id_goal;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_GetAll`()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_goal,
|
||||||
|
id_goal_parent,
|
||||||
|
id_student,
|
||||||
|
id_user_created,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
category,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM goal
|
||||||
|
ORDER BY id_goal;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_GetById`(IN p_id_goal CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_goal,
|
||||||
|
id_goal_parent,
|
||||||
|
id_student,
|
||||||
|
id_user_created,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
category,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM goal
|
||||||
|
WHERE id_goal = p_id_goal
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Insert`(
|
||||||
|
IN p_id_goal CHAR(36),
|
||||||
|
IN p_id_goal_parent CHAR(36),
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
|
IN p_id_user_created CHAR(36),
|
||||||
|
IN p_title VARCHAR(255),
|
||||||
|
IN p_description TEXT,
|
||||||
|
IN p_category VARCHAR(100)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO goal
|
||||||
|
(
|
||||||
|
id_goal,
|
||||||
|
id_goal_parent,
|
||||||
|
id_student,
|
||||||
|
id_user_created,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
category,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_goal,
|
||||||
|
p_id_goal_parent,
|
||||||
|
p_id_student,
|
||||||
|
p_id_user_created,
|
||||||
|
p_title,
|
||||||
|
p_description,
|
||||||
|
p_category,
|
||||||
|
UTC_TIMESTAMP(),
|
||||||
|
UTC_TIMESTAMP()
|
||||||
|
);
|
||||||
|
SELECT
|
||||||
|
id_goal,
|
||||||
|
id_goal_parent,
|
||||||
|
id_student,
|
||||||
|
id_user_created,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
category,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM goal
|
||||||
|
WHERE id_goal = p_id_goal
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Goal_Update`(
|
||||||
|
IN p_id_goal CHAR(36),
|
||||||
|
IN p_id_goal_parent CHAR(36),
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
|
IN p_id_user_created CHAR(36),
|
||||||
|
IN p_title VARCHAR(255),
|
||||||
|
IN p_description TEXT,
|
||||||
|
IN p_category VARCHAR(100)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
UPDATE goal
|
||||||
|
SET
|
||||||
|
id_goal_parent = COALESCE(p_id_goal_parent, id_goal_parent),
|
||||||
|
id_student = COALESCE(p_id_student, id_student),
|
||||||
|
id_user_created = COALESCE(p_id_user_created, id_user_created),
|
||||||
|
title = COALESCE(p_title, title),
|
||||||
|
description = COALESCE(p_description, description),
|
||||||
|
category = COALESCE(p_category, category),
|
||||||
|
updated_at = UTC_TIMESTAMP()
|
||||||
|
WHERE id_goal = p_id_goal;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Program_Delete`(IN p_id_program CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM program
|
||||||
|
WHERE id_program = p_id_program;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Program_GetAll`()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_program,
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
created_at
|
||||||
|
FROM program
|
||||||
|
ORDER BY id_program;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Program_GetById`(IN p_id_program CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_program,
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
created_at
|
||||||
|
FROM program
|
||||||
|
WHERE id_program = p_id_program
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Program_Insert`(
|
||||||
|
IN p_id_program CHAR(36),
|
||||||
|
IN p_id_school_district CHAR(36),
|
||||||
|
IN p_name VARCHAR(255),
|
||||||
|
IN p_description TEXT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO program
|
||||||
|
(
|
||||||
|
id_program,
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
created_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_program,
|
||||||
|
p_id_school_district,
|
||||||
|
p_name,
|
||||||
|
p_description,
|
||||||
|
UTC_TIMESTAMP()
|
||||||
|
);
|
||||||
|
SELECT
|
||||||
|
id_program,
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
created_at
|
||||||
|
FROM program
|
||||||
|
WHERE id_program = p_id_program
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Program_Update`(
|
||||||
|
IN p_id_program CHAR(36),
|
||||||
|
IN p_id_school_district CHAR(36),
|
||||||
|
IN p_name VARCHAR(255),
|
||||||
|
IN p_description TEXT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
UPDATE program
|
||||||
|
SET
|
||||||
|
id_school_district = COALESCE(p_id_school_district, id_school_district),
|
||||||
|
name = COALESCE(p_name, name),
|
||||||
|
description = COALESCE(p_description, description)
|
||||||
|
WHERE id_program = p_id_program;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Delete`(IN p_id_progress_event CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM progress_event
|
||||||
|
WHERE id_progress_event = p_id_progress_event;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_GetAll`()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_progress_event,
|
||||||
|
id_student,
|
||||||
|
id_goal,
|
||||||
|
id_user_created,
|
||||||
|
content,
|
||||||
|
is_sensitive,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM progress_event
|
||||||
|
ORDER BY id_progress_event;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_GetById`(IN p_id_progress_event CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_progress_event,
|
||||||
|
id_student,
|
||||||
|
id_goal,
|
||||||
|
id_user_created,
|
||||||
|
content,
|
||||||
|
is_sensitive,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM progress_event
|
||||||
|
WHERE id_progress_event = p_id_progress_event
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Insert`(
|
||||||
|
IN p_id_progress_event CHAR(36),
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
|
IN p_id_goal CHAR(36),
|
||||||
|
IN p_id_user_created CHAR(36),
|
||||||
|
IN p_content TEXT,
|
||||||
|
IN p_is_sensitive TINYINT(1)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO progress_event
|
||||||
|
(
|
||||||
|
id_progress_event,
|
||||||
|
id_student,
|
||||||
|
id_goal,
|
||||||
|
id_user_created,
|
||||||
|
content,
|
||||||
|
is_sensitive,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_progress_event,
|
||||||
|
p_id_student,
|
||||||
|
p_id_goal,
|
||||||
|
p_id_user_created,
|
||||||
|
p_content,
|
||||||
|
p_is_sensitive,
|
||||||
|
UTC_TIMESTAMP(),
|
||||||
|
UTC_TIMESTAMP()
|
||||||
|
);
|
||||||
|
SELECT
|
||||||
|
id_progress_event,
|
||||||
|
id_student,
|
||||||
|
id_goal,
|
||||||
|
id_user_created,
|
||||||
|
content,
|
||||||
|
is_sensitive,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM progress_event
|
||||||
|
WHERE id_progress_event = p_id_progress_event
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_ProgressEvent_Update`(
|
||||||
|
IN p_id_progress_event CHAR(36),
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
|
IN p_id_goal CHAR(36),
|
||||||
|
IN p_id_user_created CHAR(36),
|
||||||
|
IN p_content TEXT,
|
||||||
|
IN p_is_sensitive TINYINT(1)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
UPDATE progress_event
|
||||||
|
SET
|
||||||
|
id_student = COALESCE(p_id_student, id_student),
|
||||||
|
id_goal = COALESCE(p_id_goal, id_goal),
|
||||||
|
id_user_created = COALESCE(p_id_user_created, id_user_created),
|
||||||
|
content = COALESCE(p_content, content),
|
||||||
|
is_sensitive = COALESCE(p_is_sensitive, is_sensitive),
|
||||||
|
updated_at = UTC_TIMESTAMP()
|
||||||
|
WHERE id_progress_event = p_id_progress_event;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_RefreshToken_Create`(
|
||||||
|
IN p_id_refresh_token CHAR(36),
|
||||||
|
IN p_id_user CHAR(36),
|
||||||
|
IN p_token_hash VARCHAR(512),
|
||||||
|
IN p_token_salt VARCHAR(512),
|
||||||
|
IN p_expires_in_seconds INT,
|
||||||
|
IN p_device_info VARCHAR(255),
|
||||||
|
IN p_user_agent VARCHAR(512)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO refresh_token
|
||||||
|
(
|
||||||
|
id_refresh_token,
|
||||||
|
id_user,
|
||||||
|
token_hash,
|
||||||
|
token_salt,
|
||||||
|
expires_at,
|
||||||
|
device_info,
|
||||||
|
user_agent
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_refresh_token,
|
||||||
|
p_id_user,
|
||||||
|
p_token_hash,
|
||||||
|
p_token_salt,
|
||||||
|
DATE_ADD(UTC_TIMESTAMP(), INTERVAL p_expires_in_seconds SECOND),
|
||||||
|
p_device_info,
|
||||||
|
p_user_agent
|
||||||
|
);
|
||||||
|
SELECT p_id_refresh_token AS id_refresh_token;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_RefreshToken_GetById`(IN p_id_refresh_token CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_refresh_token,
|
||||||
|
id_user,
|
||||||
|
token_hash,
|
||||||
|
token_salt,
|
||||||
|
expires_at,
|
||||||
|
last_used_at,
|
||||||
|
revoked_at,
|
||||||
|
device_info,
|
||||||
|
user_agent,
|
||||||
|
replaced_by_token_id,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM refresh_token
|
||||||
|
WHERE id_refresh_token = p_id_refresh_token
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_RefreshToken_Replace`(
|
||||||
|
IN p_old_token_id CHAR(36),
|
||||||
|
IN p_id_refresh_token CHAR(36),
|
||||||
|
IN p_id_user CHAR(36),
|
||||||
|
IN p_token_hash VARCHAR(512),
|
||||||
|
IN p_token_salt VARCHAR(512),
|
||||||
|
IN p_expires_in_seconds INT,
|
||||||
|
IN p_device_info VARCHAR(255),
|
||||||
|
IN p_user_agent VARCHAR(512)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
-- Revoke the old token
|
||||||
|
UPDATE refresh_token
|
||||||
|
SET revoked_at = UTC_TIMESTAMP()
|
||||||
|
WHERE id_refresh_token = p_old_token_id
|
||||||
|
AND revoked_at IS NULL;
|
||||||
|
-- Create the new token
|
||||||
|
INSERT INTO refresh_token
|
||||||
|
(
|
||||||
|
id_refresh_token,
|
||||||
|
id_user,
|
||||||
|
token_hash,
|
||||||
|
token_salt,
|
||||||
|
expires_at,
|
||||||
|
device_info,
|
||||||
|
user_agent
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_refresh_token,
|
||||||
|
p_id_user,
|
||||||
|
p_token_hash,
|
||||||
|
p_token_salt,
|
||||||
|
DATE_ADD(UTC_TIMESTAMP(), INTERVAL p_expires_in_seconds SECOND),
|
||||||
|
p_device_info,
|
||||||
|
p_user_agent
|
||||||
|
);
|
||||||
|
-- Link old token to new one
|
||||||
|
UPDATE refresh_token
|
||||||
|
SET replaced_by_token_id = p_id_refresh_token
|
||||||
|
WHERE id_refresh_token = p_old_token_id;
|
||||||
|
SELECT p_id_refresh_token AS id_refresh_token;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_RefreshToken_Revoke`(IN p_id_refresh_token CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
UPDATE refresh_token
|
||||||
|
SET revoked_at = UTC_TIMESTAMP()
|
||||||
|
WHERE id_refresh_token = p_id_refresh_token
|
||||||
|
AND revoked_at IS NULL;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SchoolDistrict_Delete`(IN p_id_school_district CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
DELETE FROM school_district
|
||||||
|
WHERE id_school_district = p_id_school_district;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SchoolDistrict_GetAll`()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
contact_email,
|
||||||
|
created_at
|
||||||
|
FROM school_district
|
||||||
|
ORDER BY id_school_district;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SchoolDistrict_GetById`(IN p_id_school_district CHAR(36))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
contact_email,
|
||||||
|
created_at
|
||||||
|
FROM school_district
|
||||||
|
WHERE id_school_district = p_id_school_district
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SchoolDistrict_Insert`(
|
||||||
|
IN p_id_school_district CHAR(36),
|
||||||
|
IN p_name VARCHAR(255),
|
||||||
|
IN p_contact_email VARCHAR(255)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO school_district
|
||||||
|
(
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
contact_email,
|
||||||
|
created_at
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
p_id_school_district,
|
||||||
|
p_name,
|
||||||
|
p_contact_email,
|
||||||
|
UTC_TIMESTAMP()
|
||||||
|
);
|
||||||
|
SELECT
|
||||||
|
id_school_district,
|
||||||
|
name,
|
||||||
|
contact_email,
|
||||||
|
created_at
|
||||||
|
FROM school_district
|
||||||
|
WHERE id_school_district = p_id_school_district
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SchoolDistrict_Update`(
|
||||||
|
IN p_id_school_district CHAR(36),
|
||||||
|
IN p_name VARCHAR(255),
|
||||||
|
IN p_contact_email VARCHAR(255)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
UPDATE school_district
|
||||||
|
SET
|
||||||
|
name = COALESCE(p_name, name),
|
||||||
|
contact_email = COALESCE(p_contact_email, contact_email)
|
||||||
|
WHERE id_school_district = p_id_school_district;
|
||||||
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_SeedData_1`()
|
||||||
|
BEGIN
|
||||||
|
-- =============================================================================
|
||||||
|
-- Seed Data Script - create minimal set of working data
|
||||||
|
-- =============================================================================
|
||||||
|
-- =============================================================================
|
||||||
|
-- 1. SCHOOL DISTRICT
|
||||||
|
-- =============================================================================
|
||||||
|
INSERT INTO school_district (id_school_district, name, contact_email, created_at)
|
||||||
|
VALUES ('a1b2c3d4-0001-4000-a000-000000000001', 'Parent District', 'contact@dummydistrict.edu', UTC_TIMESTAMP());
|
||||||
|
-- =============================================================================
|
||||||
|
-- 2. PROGRAM (child of the district above)
|
||||||
|
-- =============================================================================
|
||||||
|
INSERT INTO program (id_program, id_school_district, name, description, created_at)
|
||||||
|
VALUES ('b2c3d4e5-0001-4000-a000-000000000001', 'a1b2c3d4-0001-4000-a000-000000000001', 'Test Program', 'A sample program for testing', UTC_TIMESTAMP());
|
||||||
|
-- =============================================================================
|
||||||
|
-- 3. ROLES
|
||||||
|
-- =============================================================================
|
||||||
|
INSERT INTO role (id_role, name, internal_name, description, created_at) VALUES
|
||||||
|
('c3d4e5f6-0001-4000-a000-000000000001', 'Super Admin', 'super_admin', 'Full system access', UTC_TIMESTAMP()),
|
||||||
|
('c3d4e5f6-0002-4000-a000-000000000001', 'District Admin', 'district_admin', 'District-level administration', UTC_TIMESTAMP()),
|
||||||
|
('c3d4e5f6-0003-4000-a000-000000000001', 'Program Admin', 'program_admin', 'Program-level administration', UTC_TIMESTAMP()),
|
||||||
|
('c3d4e5f6-0004-4000-a000-000000000001', 'Teacher', 'teacher', 'Teacher role', UTC_TIMESTAMP()),
|
||||||
|
('c3d4e5f6-0005-4000-a000-000000000001', 'Paraeducator', 'paraeducator', 'Paraeducator role', UTC_TIMESTAMP()),
|
||||||
|
('c3d4e5f6-0006-4000-a000-000000000001', 'Student', 'student', 'Student role', UTC_TIMESTAMP());
|
||||||
|
-- =============================================================================
|
||||||
|
-- 4. USERS ? 2 Teachers + 1 Paraeducator
|
||||||
|
-- =============================================================================
|
||||||
|
-- Teacher 1
|
||||||
|
INSERT INTO user (id_user, id_role, email, name, password_hash, password_salt, created_at)
|
||||||
|
VALUES ('d4e5f6a7-0001-4000-a000-000000000001', 'c3d4e5f6-0004-4000-a000-000000000001',
|
||||||
|
'teacher1@example.com', 'Teacher One', NULL, NULL, UTC_TIMESTAMP());
|
||||||
|
-- Teacher 2
|
||||||
|
INSERT INTO user (id_user, id_role, email, name, password_hash, password_salt, created_at)
|
||||||
|
VALUES ('d4e5f6a7-0002-4000-a000-000000000001', 'c3d4e5f6-0004-4000-a000-000000000001',
|
||||||
|
'teacher2@example.com', 'Teacher Two', NULL, NULL, UTC_TIMESTAMP());
|
||||||
|
-- Paraeducator 1
|
||||||
|
INSERT INTO user (id_user, id_role, email, name, password_hash, password_salt, created_at)
|
||||||
|
VALUES ('d4e5f6a7-0003-4000-a000-000000000001', 'c3d4e5f6-0005-4000-a000-000000000001',
|
||||||
|
'para1@example.com', 'Para One', NULL, NULL, UTC_TIMESTAMP());
|
||||||
|
-- =============================================================================
|
||||||
|
-- 5. USER_PROGRAM ? link all 3 users to the program
|
||||||
|
-- =============================================================================
|
||||||
|
INSERT INTO user_program (id_user_program, id_user, id_program, is_primary, status, joined_at) VALUES
|
||||||
|
('e5f6a7b8-0001-4000-a000-000000000001', 'd4e5f6a7-0001-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 1, 'active', UTC_TIMESTAMP()),
|
||||||
|
('e5f6a7b8-0002-4000-a000-000000000001', 'd4e5f6a7-0002-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 1, 'active', UTC_TIMESTAMP()),
|
||||||
|
('e5f6a7b8-0003-4000-a000-000000000001', 'd4e5f6a7-0003-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 1, 'active', UTC_TIMESTAMP());
|
||||||
|
-- =============================================================================
|
||||||
|
-- 6. STUDENTS ? 5 students under the program
|
||||||
|
-- =============================================================================
|
||||||
|
INSERT INTO student (id_student, id_program, identifier, program_year, enrollment_date, expected_grad, created_at) VALUES
|
||||||
|
('f6a7b8c9-0001-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 'STU-001', 1, '2025-09-01', '2029-06-15', UTC_TIMESTAMP()),
|
||||||
|
('f6a7b8c9-0002-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 'STU-002', 1, '2025-09-01', '2029-06-15', UTC_TIMESTAMP()),
|
||||||
|
('f6a7b8c9-0003-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 'STU-003', 2, '2024-09-01', '2028-06-15', UTC_TIMESTAMP()),
|
||||||
|
('f6a7b8c9-0004-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 'STU-004', 2, '2024-09-01', '2028-06-15', UTC_TIMESTAMP()),
|
||||||
|
('f6a7b8c9-0005-4000-a000-000000000001', 'b2c3d4e5-0001-4000-a000-000000000001', 'STU-005', 3, '2023-09-01', '2027-06-15', UTC_TIMESTAMP());
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
DROP PROCEDURE IF EXISTS sp_Student_Delete;
|
DELIMITER ;;
|
||||||
DELIMITER $$
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_Delete`(IN p_id_student CHAR(36))
|
||||||
|
|
||||||
CREATE PROCEDURE sp_Student_Delete(IN p_id_student INT)
|
|
||||||
BEGIN
|
BEGIN
|
||||||
DELETE FROM student
|
DELETE FROM student
|
||||||
WHERE id_student = p_id_student;
|
WHERE id_student = p_id_student;
|
||||||
|
|
||||||
SELECT ROW_COUNT() AS rows_affected;
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
END$$
|
END;;
|
||||||
|
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
DROP PROCEDURE IF EXISTS sp_Student_GetAll;
|
DELIMITER ;;
|
||||||
DELIMITER $$
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_GetAll`()
|
||||||
|
|
||||||
CREATE PROCEDURE sp_Student_GetAll()
|
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
id_student,
|
id_student,
|
||||||
@@ -13,6 +11,5 @@ BEGIN
|
|||||||
created_at
|
created_at
|
||||||
FROM student
|
FROM student
|
||||||
ORDER BY id_student;
|
ORDER BY id_student;
|
||||||
END$$
|
END;;
|
||||||
|
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
DROP PROCEDURE IF EXISTS sp_Student_GetById;
|
DELIMITER ;;
|
||||||
DELIMITER $$
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_GetById`(IN p_id_student CHAR(36))
|
||||||
|
|
||||||
CREATE PROCEDURE sp_Student_GetById(IN p_id_student INT)
|
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
id_student,
|
id_student,
|
||||||
@@ -14,6 +12,5 @@ BEGIN
|
|||||||
FROM student
|
FROM student
|
||||||
WHERE id_student = p_id_student
|
WHERE id_student = p_id_student
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
END$$
|
END;;
|
||||||
|
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
DROP PROCEDURE IF EXISTS sp_Student_Insert;
|
DELIMITER ;;
|
||||||
DELIMITER $$
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_Insert`(
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
CREATE PROCEDURE sp_Student_Insert(
|
IN p_id_program CHAR(36),
|
||||||
IN p_id_student INT,
|
|
||||||
IN p_id_program INT,
|
|
||||||
IN p_identifier VARCHAR(50),
|
IN p_identifier VARCHAR(50),
|
||||||
IN p_program_year INT,
|
IN p_program_year INT,
|
||||||
IN p_enrollment_date DATE,
|
IN p_enrollment_date DATE,
|
||||||
@@ -30,7 +28,6 @@ BEGIN
|
|||||||
p_expected_grad,
|
p_expected_grad,
|
||||||
UTC_TIMESTAMP()
|
UTC_TIMESTAMP()
|
||||||
);
|
);
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
id_student,
|
id_student,
|
||||||
id_program,
|
id_program,
|
||||||
@@ -42,6 +39,5 @@ BEGIN
|
|||||||
FROM student
|
FROM student
|
||||||
WHERE id_student = p_id_student
|
WHERE id_student = p_id_student
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
END$$
|
END;;
|
||||||
|
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
DROP PROCEDURE IF EXISTS sp_Student_Update;
|
DELIMITER ;;
|
||||||
DELIMITER $$
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_Student_Update`(
|
||||||
|
IN p_id_student CHAR(36),
|
||||||
CREATE PROCEDURE sp_Student_Update(
|
IN p_id_program CHAR(36),
|
||||||
IN p_id_student INT,
|
|
||||||
IN p_id_program INT,
|
|
||||||
IN p_identifier VARCHAR(50),
|
IN p_identifier VARCHAR(50),
|
||||||
IN p_program_year INT,
|
IN p_program_year INT,
|
||||||
IN p_enrollment_date DATE,
|
IN p_enrollment_date DATE,
|
||||||
@@ -18,8 +16,6 @@ BEGIN
|
|||||||
enrollment_date = COALESCE(p_enrollment_date, enrollment_date),
|
enrollment_date = COALESCE(p_enrollment_date, enrollment_date),
|
||||||
expected_grad = COALESCE(p_expected_grad, expected_grad)
|
expected_grad = COALESCE(p_expected_grad, expected_grad)
|
||||||
WHERE id_student = p_id_student;
|
WHERE id_student = p_id_student;
|
||||||
|
|
||||||
SELECT ROW_COUNT() AS rows_affected;
|
SELECT ROW_COUNT() AS rows_affected;
|
||||||
END$$
|
END;;
|
||||||
|
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_User_GetByEmail`(IN p_email VARCHAR(255))
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
u.id_user,
|
||||||
|
u.id_role,
|
||||||
|
u.email,
|
||||||
|
u.name,
|
||||||
|
u.password_hash,
|
||||||
|
u.password_salt,
|
||||||
|
u.failed_login_attempts,
|
||||||
|
u.locked_until,
|
||||||
|
u.created_at,
|
||||||
|
r.internal_name AS role_internal_name,
|
||||||
|
r.name AS role_display_name
|
||||||
|
FROM `user` u
|
||||||
|
LEFT JOIN role r ON u.id_role = r.id_role
|
||||||
|
WHERE u.email = p_email
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
DELIMITER ;;
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `sp_User_GetById`(IN p_id_user INT)
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
u.id_user,
|
||||||
|
u.id_role,
|
||||||
|
u.email,
|
||||||
|
u.name,
|
||||||
|
u.password_hash,
|
||||||
|
u.password_salt,
|
||||||
|
u.failed_login_attempts,
|
||||||
|
u.locked_until,
|
||||||
|
u.created_at,
|
||||||
|
r.internal_name AS role_internal_name,
|
||||||
|
r.name AS role_display_name
|
||||||
|
FROM `user` u
|
||||||
|
LEFT JOIN role r ON u.id_role = r.id_role
|
||||||
|
WHERE u.id_user = p_id_user
|
||||||
|
LIMIT 1;
|
||||||
|
END;;
|
||||||
|
DELIMITER ;
|
||||||
@@ -1,239 +0,0 @@
|
|||||||
-- ============================================================
|
|
||||||
-- WinStudentGoalTracker - All Table Definitions
|
|
||||||
-- Generated: 2026-02-18
|
|
||||||
-- ============================================================
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables with no foreign key dependencies
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- permission
|
|
||||||
CREATE TABLE `permission` (
|
|
||||||
`id_permission` int NOT NULL,
|
|
||||||
`name` varchar(100) DEFAULT NULL,
|
|
||||||
`description` text,
|
|
||||||
`resource` varchar(100) DEFAULT NULL,
|
|
||||||
`action` varchar(50) DEFAULT NULL,
|
|
||||||
`scope` varchar(50) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_permission`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- role
|
|
||||||
CREATE TABLE `role` (
|
|
||||||
`id_role` int NOT NULL,
|
|
||||||
`name` varchar(100) DEFAULT NULL,
|
|
||||||
`description` text,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_role`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- school_district
|
|
||||||
CREATE TABLE `school_district` (
|
|
||||||
`id_school_district` int NOT NULL,
|
|
||||||
`name` varchar(255) DEFAULT NULL,
|
|
||||||
`contact_email` varchar(255) DEFAULT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_school_district`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables depending on role
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- role_permission
|
|
||||||
CREATE TABLE `role_permission` (
|
|
||||||
`id_role_permission` int NOT NULL,
|
|
||||||
`id_role` int DEFAULT NULL,
|
|
||||||
`id_permission` int DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_role_permission`),
|
|
||||||
KEY `id_role` (`id_role`),
|
|
||||||
KEY `id_permission` (`id_permission`),
|
|
||||||
CONSTRAINT `role_permission_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`),
|
|
||||||
CONSTRAINT `role_permission_ibfk_2` FOREIGN KEY (`id_permission`) REFERENCES `permission` (`id_permission`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- user
|
|
||||||
CREATE TABLE `user` (
|
|
||||||
`id_user` int NOT NULL,
|
|
||||||
`id_role` int DEFAULT NULL,
|
|
||||||
`email` varchar(255) DEFAULT NULL,
|
|
||||||
`name` varchar(255) DEFAULT NULL,
|
|
||||||
`password_hash` varchar(255) DEFAULT NULL,
|
|
||||||
`password_updated_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`failed_login_attempts` int DEFAULT '0',
|
|
||||||
`locked_until` timestamp NULL DEFAULT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_user`),
|
|
||||||
KEY `id_role` (`id_role`),
|
|
||||||
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables depending on school_district
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- program
|
|
||||||
CREATE TABLE `program` (
|
|
||||||
`id_program` int NOT NULL,
|
|
||||||
`id_school_district` int DEFAULT NULL,
|
|
||||||
`name` varchar(255) DEFAULT NULL,
|
|
||||||
`description` text,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_program`),
|
|
||||||
KEY `id_school_district` (`id_school_district`),
|
|
||||||
CONSTRAINT `program_ibfk_1` FOREIGN KEY (`id_school_district`) REFERENCES `school_district` (`id_school_district`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables depending on user and/or program
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- password_history
|
|
||||||
CREATE TABLE `password_history` (
|
|
||||||
`id_password_history` int NOT NULL,
|
|
||||||
`id_user` int DEFAULT NULL,
|
|
||||||
`password_hash` varchar(255) NOT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_password_history`),
|
|
||||||
KEY `idx_user_created` (`id_user`,`created_at`),
|
|
||||||
CONSTRAINT `password_history_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- password_reset_token
|
|
||||||
CREATE TABLE `password_reset_token` (
|
|
||||||
`id_password_reset_token` int NOT NULL,
|
|
||||||
`id_user` int DEFAULT NULL,
|
|
||||||
`token_hash` varchar(255) DEFAULT NULL,
|
|
||||||
`expires_at` timestamp NOT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`used_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`invalidated_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`request_ip` varchar(45) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_password_reset_token`),
|
|
||||||
UNIQUE KEY `uq_token_hash` (`token_hash`),
|
|
||||||
KEY `idx_user_created` (`id_user`,`created_at`),
|
|
||||||
CONSTRAINT `password_reset_token_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- student
|
|
||||||
CREATE TABLE `student` (
|
|
||||||
`id_student` int NOT NULL,
|
|
||||||
`id_program` int DEFAULT NULL,
|
|
||||||
`identifier` varchar(50) DEFAULT NULL,
|
|
||||||
`program_year` int DEFAULT NULL,
|
|
||||||
`enrollment_date` date DEFAULT NULL,
|
|
||||||
`expected_grad` date DEFAULT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_student`),
|
|
||||||
KEY `id_program` (`id_program`),
|
|
||||||
CONSTRAINT `student_ibfk_1` FOREIGN KEY (`id_program`) REFERENCES `program` (`id_program`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- user_program
|
|
||||||
CREATE TABLE `user_program` (
|
|
||||||
`id_user_program` int NOT NULL,
|
|
||||||
`id_user` int DEFAULT NULL,
|
|
||||||
`id_program` int DEFAULT NULL,
|
|
||||||
`is_primary` tinyint(1) DEFAULT '0',
|
|
||||||
`status` varchar(20) DEFAULT 'active',
|
|
||||||
`joined_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_user_program`),
|
|
||||||
UNIQUE KEY `uq_user_program` (`id_user`,`id_program`),
|
|
||||||
KEY `idx_id_program` (`id_program`),
|
|
||||||
CONSTRAINT `user_program_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
|
|
||||||
CONSTRAINT `user_program_ibfk_2` FOREIGN KEY (`id_program`) REFERENCES `program` (`id_program`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables depending on student and user
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- user_student
|
|
||||||
CREATE TABLE `user_student` (
|
|
||||||
`id_user_student` int NOT NULL,
|
|
||||||
`id_user` int DEFAULT NULL,
|
|
||||||
`id_student` int DEFAULT NULL,
|
|
||||||
`access_level` varchar(50) DEFAULT NULL,
|
|
||||||
`is_primary` tinyint(1) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_user_student`),
|
|
||||||
KEY `id_user` (`id_user`),
|
|
||||||
KEY `id_student` (`id_student`),
|
|
||||||
CONSTRAINT `user_student_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
|
|
||||||
CONSTRAINT `user_student_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- goal (self-referencing + student + user)
|
|
||||||
CREATE TABLE `goal` (
|
|
||||||
`id_goal` int NOT NULL,
|
|
||||||
`id_goal_parent` int DEFAULT NULL,
|
|
||||||
`id_student` int DEFAULT NULL,
|
|
||||||
`id_user_created` int DEFAULT NULL,
|
|
||||||
`title` varchar(255) DEFAULT NULL,
|
|
||||||
`description` text,
|
|
||||||
`category` varchar(100) DEFAULT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`updated_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_goal`),
|
|
||||||
KEY `id_goal_parent` (`id_goal_parent`),
|
|
||||||
KEY `id_student` (`id_student`),
|
|
||||||
KEY `id_user_created` (`id_user_created`),
|
|
||||||
CONSTRAINT `goal_ibfk_1` FOREIGN KEY (`id_goal_parent`) REFERENCES `goal` (`id_goal`),
|
|
||||||
CONSTRAINT `goal_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
|
||||||
CONSTRAINT `goal_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- health_note
|
|
||||||
CREATE TABLE `health_note` (
|
|
||||||
`id_health_note` int NOT NULL,
|
|
||||||
`id_student` int DEFAULT NULL,
|
|
||||||
`id_user_created` int DEFAULT NULL,
|
|
||||||
`content` text,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_health_note`),
|
|
||||||
KEY `id_student` (`id_student`),
|
|
||||||
KEY `id_user_created` (`id_user_created`),
|
|
||||||
CONSTRAINT `health_note_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
|
||||||
CONSTRAINT `health_note_ibfk_2` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
-- Tables depending on goal, student, and user
|
|
||||||
-- -----------------------------------------------------------
|
|
||||||
|
|
||||||
-- progress_event
|
|
||||||
CREATE TABLE `progress_event` (
|
|
||||||
`id_progress_event` int NOT NULL,
|
|
||||||
`id_student` int DEFAULT NULL,
|
|
||||||
`id_goal` int DEFAULT NULL,
|
|
||||||
`id_user_created` int DEFAULT NULL,
|
|
||||||
`content` text,
|
|
||||||
`is_sensitive` tinyint(1) DEFAULT NULL,
|
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
|
||||||
`updated_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_progress_event`),
|
|
||||||
KEY `id_student` (`id_student`),
|
|
||||||
KEY `id_goal` (`id_goal`),
|
|
||||||
KEY `id_user_created` (`id_user_created`),
|
|
||||||
CONSTRAINT `progress_event_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
|
||||||
CONSTRAINT `progress_event_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
|
||||||
CONSTRAINT `progress_event_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
|
|
||||||
-- progress_report
|
|
||||||
CREATE TABLE `progress_report` (
|
|
||||||
`id_progress_report` int NOT NULL,
|
|
||||||
`id_student` int DEFAULT NULL,
|
|
||||||
`id_goal` int DEFAULT NULL,
|
|
||||||
`id_user_created` int DEFAULT NULL,
|
|
||||||
`period` varchar(10) DEFAULT NULL,
|
|
||||||
`year` int DEFAULT NULL,
|
|
||||||
`summary` text,
|
|
||||||
`generated_at` timestamp NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id_progress_report`),
|
|
||||||
KEY `id_student` (`id_student`),
|
|
||||||
KEY `id_goal` (`id_goal`),
|
|
||||||
KEY `id_user_created` (`id_user_created`),
|
|
||||||
CONSTRAINT `progress_report_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
|
||||||
CONSTRAINT `progress_report_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
|
||||||
CONSTRAINT `progress_report_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
CREATE TABLE `goal` (
|
CREATE TABLE `goal` (
|
||||||
`id_goal` int NOT NULL,
|
`id_goal` char(36) NOT NULL,
|
||||||
`id_goal_parent` int DEFAULT NULL,
|
`id_goal_parent` char(36) DEFAULT NULL,
|
||||||
`id_student` int DEFAULT NULL,
|
`id_student` char(36) DEFAULT NULL,
|
||||||
`id_user_created` int DEFAULT NULL,
|
`id_user_created` char(36) DEFAULT NULL,
|
||||||
`title` varchar(255) DEFAULT NULL,
|
`title` varchar(255) DEFAULT NULL,
|
||||||
`description` text,
|
`description` text,
|
||||||
`category` varchar(100) DEFAULT NULL,
|
`category` varchar(100) DEFAULT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
`updated_at` timestamp NULL DEFAULT NULL,
|
`updated_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_goal`),
|
PRIMARY KEY (`id_goal`),
|
||||||
KEY `id_goal_parent` (`id_goal_parent`),
|
KEY `goal_ibfk_1` (`id_goal_parent`),
|
||||||
KEY `id_student` (`id_student`),
|
KEY `goal_ibfk_2` (`id_student`),
|
||||||
KEY `id_user_created` (`id_user_created`),
|
KEY `goal_ibfk_3` (`id_user_created`),
|
||||||
CONSTRAINT `goal_ibfk_1` FOREIGN KEY (`id_goal_parent`) REFERENCES `goal` (`id_goal`),
|
CONSTRAINT `goal_ibfk_1` FOREIGN KEY (`id_goal_parent`) REFERENCES `goal` (`id_goal`),
|
||||||
CONSTRAINT `goal_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
CONSTRAINT `goal_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
||||||
CONSTRAINT `goal_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
CONSTRAINT `goal_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
CREATE TABLE `health_note` (
|
CREATE TABLE `health_note` (
|
||||||
`id_health_note` int NOT NULL,
|
`id_health_note` char(36) NOT NULL,
|
||||||
`id_student` int DEFAULT NULL,
|
`id_student` char(36) DEFAULT NULL,
|
||||||
`id_user_created` int DEFAULT NULL,
|
`id_user_created` char(36) DEFAULT NULL,
|
||||||
`content` text,
|
`content` text,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_health_note`),
|
PRIMARY KEY (`id_health_note`),
|
||||||
KEY `id_student` (`id_student`),
|
KEY `health_note_ibfk_1` (`id_student`),
|
||||||
KEY `id_user_created` (`id_user_created`),
|
KEY `health_note_ibfk_2` (`id_user_created`),
|
||||||
CONSTRAINT `health_note_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
CONSTRAINT `health_note_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
||||||
CONSTRAINT `health_note_ibfk_2` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
CONSTRAINT `health_note_ibfk_2` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE `password_history` (
|
CREATE TABLE `password_history` (
|
||||||
`id_password_history` int NOT NULL,
|
`id_password_history` char(36) NOT NULL,
|
||||||
`id_user` int DEFAULT NULL,
|
`id_user` char(36) DEFAULT NULL,
|
||||||
`password_hash` varchar(255) NOT NULL,
|
`password_hash` varchar(255) NOT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_password_history`),
|
PRIMARY KEY (`id_password_history`),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE `password_reset_token` (
|
CREATE TABLE `password_reset_token` (
|
||||||
`id_password_reset_token` int NOT NULL,
|
`id_password_reset_token` char(36) NOT NULL,
|
||||||
`id_user` int DEFAULT NULL,
|
`id_user` char(36) DEFAULT NULL,
|
||||||
`token_hash` varchar(255) DEFAULT NULL,
|
`token_hash` varchar(255) DEFAULT NULL,
|
||||||
`expires_at` timestamp NOT NULL,
|
`expires_at` timestamp NOT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
CREATE TABLE `permission` (
|
CREATE TABLE `permission` (
|
||||||
`id_permission` int NOT NULL,
|
`id_permission` char(36) NOT NULL,
|
||||||
`name` varchar(100) DEFAULT NULL,
|
`name` varchar(100) DEFAULT NULL,
|
||||||
`description` text,
|
`description` text,
|
||||||
`resource` varchar(100) DEFAULT NULL,
|
`resource` varchar(100) DEFAULT NULL,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
CREATE TABLE `program` (
|
CREATE TABLE `program` (
|
||||||
`id_program` int NOT NULL,
|
`id_program` char(36) NOT NULL,
|
||||||
`id_school_district` int DEFAULT NULL,
|
`id_school_district` char(36) DEFAULT NULL,
|
||||||
`name` varchar(255) DEFAULT NULL,
|
`name` varchar(255) DEFAULT NULL,
|
||||||
`description` text,
|
`description` text,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_program`),
|
PRIMARY KEY (`id_program`),
|
||||||
KEY `id_school_district` (`id_school_district`),
|
KEY `program_ibfk_1` (`id_school_district`),
|
||||||
CONSTRAINT `program_ibfk_1` FOREIGN KEY (`id_school_district`) REFERENCES `school_district` (`id_school_district`)
|
CONSTRAINT `program_ibfk_1` FOREIGN KEY (`id_school_district`) REFERENCES `school_district` (`id_school_district`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
CREATE TABLE `progress_event` (
|
CREATE TABLE `progress_event` (
|
||||||
`id_progress_event` int NOT NULL,
|
`id_progress_event` char(36) NOT NULL,
|
||||||
`id_student` int DEFAULT NULL,
|
`id_student` char(36) DEFAULT NULL,
|
||||||
`id_goal` int DEFAULT NULL,
|
`id_goal` char(36) DEFAULT NULL,
|
||||||
`id_user_created` int DEFAULT NULL,
|
`id_user_created` char(36) DEFAULT NULL,
|
||||||
`content` text,
|
`content` text,
|
||||||
`is_sensitive` tinyint(1) DEFAULT NULL,
|
`is_sensitive` tinyint(1) DEFAULT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
`updated_at` timestamp NULL DEFAULT NULL,
|
`updated_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_progress_event`),
|
PRIMARY KEY (`id_progress_event`),
|
||||||
KEY `id_student` (`id_student`),
|
KEY `progress_event_ibfk_1` (`id_student`),
|
||||||
KEY `id_goal` (`id_goal`),
|
KEY `progress_event_ibfk_2` (`id_goal`),
|
||||||
KEY `id_user_created` (`id_user_created`),
|
KEY `progress_event_ibfk_3` (`id_user_created`),
|
||||||
CONSTRAINT `progress_event_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
CONSTRAINT `progress_event_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
||||||
CONSTRAINT `progress_event_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
CONSTRAINT `progress_event_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
||||||
CONSTRAINT `progress_event_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
CONSTRAINT `progress_event_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
CREATE TABLE `progress_report` (
|
CREATE TABLE `progress_report` (
|
||||||
`id_progress_report` int NOT NULL,
|
`id_progress_report` char(36) NOT NULL,
|
||||||
`id_student` int DEFAULT NULL,
|
`id_student` char(36) DEFAULT NULL,
|
||||||
`id_goal` int DEFAULT NULL,
|
`id_goal` char(36) DEFAULT NULL,
|
||||||
`id_user_created` int DEFAULT NULL,
|
`id_user_created` char(36) DEFAULT NULL,
|
||||||
`period` varchar(10) DEFAULT NULL,
|
`period` varchar(10) DEFAULT NULL,
|
||||||
`year` int DEFAULT NULL,
|
`year` int DEFAULT NULL,
|
||||||
`summary` text,
|
`summary` text,
|
||||||
`generated_at` timestamp NULL DEFAULT NULL,
|
`generated_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_progress_report`),
|
PRIMARY KEY (`id_progress_report`),
|
||||||
KEY `id_student` (`id_student`),
|
KEY `progress_report_ibfk_1` (`id_student`),
|
||||||
KEY `id_goal` (`id_goal`),
|
KEY `progress_report_ibfk_2` (`id_goal`),
|
||||||
KEY `id_user_created` (`id_user_created`),
|
KEY `progress_report_ibfk_3` (`id_user_created`),
|
||||||
CONSTRAINT `progress_report_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
CONSTRAINT `progress_report_ibfk_1` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`),
|
||||||
CONSTRAINT `progress_report_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
CONSTRAINT `progress_report_ibfk_2` FOREIGN KEY (`id_goal`) REFERENCES `goal` (`id_goal`),
|
||||||
CONSTRAINT `progress_report_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
CONSTRAINT `progress_report_ibfk_3` FOREIGN KEY (`id_user_created`) REFERENCES `user` (`id_user`)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
CREATE TABLE `refresh_token` (
|
||||||
|
`id_refresh_token` char(36) NOT NULL,
|
||||||
|
`id_user` char(36) NOT NULL,
|
||||||
|
`token_hash` varchar(512) NOT NULL,
|
||||||
|
`token_salt` varchar(512) NOT NULL,
|
||||||
|
`expires_at` timestamp NOT NULL,
|
||||||
|
`last_used_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`revoked_at` timestamp NULL DEFAULT NULL,
|
||||||
|
`device_info` varchar(255) DEFAULT NULL,
|
||||||
|
`user_agent` varchar(512) DEFAULT NULL,
|
||||||
|
`replaced_by_token_id` char(36) DEFAULT NULL,
|
||||||
|
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`id_refresh_token`),
|
||||||
|
KEY `idx_refresh_token_user` (`id_user`),
|
||||||
|
KEY `idx_refresh_token_expires` (`expires_at`),
|
||||||
|
KEY `refresh_token_ibfk_2` (`replaced_by_token_id`),
|
||||||
|
CONSTRAINT `refresh_token_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
|
||||||
|
CONSTRAINT `refresh_token_ibfk_2` FOREIGN KEY (`replaced_by_token_id`) REFERENCES `refresh_token` (`id_refresh_token`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
CREATE TABLE `role` (
|
CREATE TABLE `role` (
|
||||||
`id_role` int NOT NULL,
|
`id_role` char(36) NOT NULL,
|
||||||
`name` varchar(100) DEFAULT NULL,
|
`name` varchar(100) DEFAULT NULL,
|
||||||
|
`internal_name` varchar(100) DEFAULT NULL,
|
||||||
`description` text,
|
`description` text,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_role`)
|
PRIMARY KEY (`id_role`)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
CREATE TABLE `role_permission` (
|
CREATE TABLE `role_permission` (
|
||||||
`id_role_permission` int NOT NULL,
|
`id_role_permission` char(36) NOT NULL,
|
||||||
`id_role` int DEFAULT NULL,
|
`id_role` char(36) DEFAULT NULL,
|
||||||
`id_permission` int DEFAULT NULL,
|
`id_permission` char(36) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_role_permission`),
|
PRIMARY KEY (`id_role_permission`),
|
||||||
KEY `id_role` (`id_role`),
|
KEY `role_permission_ibfk_1` (`id_role`),
|
||||||
KEY `id_permission` (`id_permission`),
|
KEY `role_permission_ibfk_2` (`id_permission`),
|
||||||
CONSTRAINT `role_permission_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`),
|
CONSTRAINT `role_permission_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`),
|
||||||
CONSTRAINT `role_permission_ibfk_2` FOREIGN KEY (`id_permission`) REFERENCES `permission` (`id_permission`)
|
CONSTRAINT `role_permission_ibfk_2` FOREIGN KEY (`id_permission`) REFERENCES `permission` (`id_permission`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
CREATE TABLE `school_district` (
|
CREATE TABLE `school_district` (
|
||||||
`id_school_district` int NOT NULL,
|
`id_school_district` char(36) NOT NULL,
|
||||||
`name` varchar(255) DEFAULT NULL,
|
`name` varchar(255) DEFAULT NULL,
|
||||||
`contact_email` varchar(255) DEFAULT NULL,
|
`contact_email` varchar(255) DEFAULT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
CREATE TABLE `student` (
|
CREATE TABLE `student` (
|
||||||
`id_student` int NOT NULL,
|
`id_student` char(36) NOT NULL,
|
||||||
`id_program` int DEFAULT NULL,
|
`id_program` char(36) DEFAULT NULL,
|
||||||
`identifier` varchar(50) DEFAULT NULL,
|
`identifier` varchar(50) DEFAULT NULL,
|
||||||
`program_year` int DEFAULT NULL,
|
`program_year` int DEFAULT NULL,
|
||||||
`enrollment_date` date DEFAULT NULL,
|
`enrollment_date` date DEFAULT NULL,
|
||||||
`expected_grad` date DEFAULT NULL,
|
`expected_grad` date DEFAULT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_student`),
|
PRIMARY KEY (`id_student`),
|
||||||
KEY `id_program` (`id_program`),
|
KEY `student_ibfk_1` (`id_program`),
|
||||||
CONSTRAINT `student_ibfk_1` FOREIGN KEY (`id_program`) REFERENCES `program` (`id_program`)
|
CONSTRAINT `student_ibfk_1` FOREIGN KEY (`id_program`) REFERENCES `program` (`id_program`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
CREATE TABLE `user` (
|
CREATE TABLE `user` (
|
||||||
`id_user` int NOT NULL,
|
`id_user` char(36) NOT NULL,
|
||||||
`id_role` int DEFAULT NULL,
|
`id_role` char(36) DEFAULT NULL,
|
||||||
`email` varchar(255) DEFAULT NULL,
|
`email` varchar(255) DEFAULT NULL,
|
||||||
`name` varchar(255) DEFAULT NULL,
|
`name` varchar(255) DEFAULT NULL,
|
||||||
`password_hash` varchar(255) DEFAULT NULL,
|
`password_hash` varchar(255) DEFAULT NULL,
|
||||||
|
`password_salt` varchar(255) DEFAULT NULL,
|
||||||
`password_updated_at` timestamp NULL DEFAULT NULL,
|
`password_updated_at` timestamp NULL DEFAULT NULL,
|
||||||
`failed_login_attempts` int DEFAULT '0',
|
`failed_login_attempts` int DEFAULT '0',
|
||||||
`locked_until` timestamp NULL DEFAULT NULL,
|
`locked_until` timestamp NULL DEFAULT NULL,
|
||||||
`created_at` timestamp NULL DEFAULT NULL,
|
`created_at` timestamp NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_user`),
|
PRIMARY KEY (`id_user`),
|
||||||
KEY `id_role` (`id_role`),
|
KEY `user_ibfk_1` (`id_role`),
|
||||||
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`)
|
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`id_role`) REFERENCES `role` (`id_role`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
CREATE TABLE `user_program` (
|
CREATE TABLE `user_program` (
|
||||||
`id_user_program` int NOT NULL,
|
`id_user_program` char(36) NOT NULL,
|
||||||
`id_user` int DEFAULT NULL,
|
`id_user` char(36) DEFAULT NULL,
|
||||||
`id_program` int DEFAULT NULL,
|
`id_program` char(36) DEFAULT NULL,
|
||||||
`is_primary` tinyint(1) DEFAULT '0',
|
`is_primary` tinyint(1) DEFAULT '0',
|
||||||
`status` varchar(20) DEFAULT 'active',
|
`status` varchar(20) DEFAULT 'active',
|
||||||
`joined_at` timestamp NULL DEFAULT NULL,
|
`joined_at` timestamp NULL DEFAULT NULL,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
CREATE TABLE `user_student` (
|
CREATE TABLE `user_student` (
|
||||||
`id_user_student` int NOT NULL,
|
`id_user_student` char(36) NOT NULL,
|
||||||
`id_user` int DEFAULT NULL,
|
`id_user` char(36) DEFAULT NULL,
|
||||||
`id_student` int DEFAULT NULL,
|
`id_student` char(36) DEFAULT NULL,
|
||||||
`access_level` varchar(50) DEFAULT NULL,
|
`access_level` varchar(50) DEFAULT NULL,
|
||||||
`is_primary` tinyint(1) DEFAULT NULL,
|
`is_primary` tinyint(1) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id_user_student`),
|
PRIMARY KEY (`id_user_student`),
|
||||||
KEY `id_user` (`id_user`),
|
KEY `user_student_ibfk_1` (`id_user`),
|
||||||
KEY `id_student` (`id_student`),
|
KEY `user_student_ibfk_2` (`id_student`),
|
||||||
CONSTRAINT `user_student_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
|
CONSTRAINT `user_student_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
|
||||||
CONSTRAINT `user_student_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`)
|
CONSTRAINT `user_student_ibfk_2` FOREIGN KEY (`id_student`) REFERENCES `student` (`id_student`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||||
|
|||||||
Reference in New Issue
Block a user