@@ -45,6 +45,7 @@ public static function create()
4545 public function install ()
4646 {
4747 $ this ->setUpExtraFields ();
48+ $ this ->setUpDatabaseTables ();
4849 }
4950
5051 /**
@@ -801,6 +802,79 @@ private function setDownExtraFields()
801802 }
802803
803804
805+ /**
806+ * Create plugin-specific migration support tables.
807+ *
808+ * These tables keep custom grading/tracking structures outside the core schema.
809+ * They intentionally use generic plugin table names instead of the legacy table names.
810+ */
811+ private function setUpDatabaseTables (): void
812+ {
813+ Database::query (<<<'SQL'
814+ CREATE TABLE IF NOT EXISTS plugin_grading_electronic_lp_completion (
815+ id BIGINT AUTO_INCREMENT NOT NULL,
816+ course_id INT NOT NULL,
817+ user_id BIGINT NOT NULL,
818+ lp_id INT NOT NULL,
819+ completion_status VARCHAR(250) NOT NULL,
820+ INDEX idx_pge_lp_completion_course_user_lp (course_id, user_id, lp_id),
821+ INDEX idx_pge_lp_completion_lp (lp_id),
822+ PRIMARY KEY(id)
823+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
824+ SQL);
825+
826+ Database::query (<<<'SQL'
827+ CREATE TABLE IF NOT EXISTS plugin_grading_electronic_lp_schedule (
828+ id INT AUTO_INCREMENT NOT NULL,
829+ course_id BIGINT NOT NULL,
830+ lp_id BIGINT NOT NULL,
831+ title VARCHAR(100) DEFAULT NULL,
832+ week_day VARCHAR(100) DEFAULT NULL,
833+ INDEX idx_pge_lp_schedule_course_lp (course_id, lp_id),
834+ PRIMARY KEY(id)
835+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
836+ SQL);
837+
838+ Database::query (<<<'SQL'
839+ CREATE TABLE IF NOT EXISTS plugin_grading_electronic_forum_thread_comment (
840+ id BIGINT AUTO_INCREMENT NOT NULL,
841+ sender_user_id BIGINT NOT NULL,
842+ receiver_user_id BIGINT NOT NULL,
843+ forum_id BIGINT NOT NULL,
844+ thread_id BIGINT NOT NULL,
845+ comment BLOB NOT NULL,
846+ INDEX idx_pge_forum_thread_comment_forum_thread (forum_id, thread_id),
847+ INDEX idx_pge_forum_thread_comment_receiver (receiver_user_id),
848+ INDEX idx_pge_forum_thread_comment_sender (sender_user_id),
849+ PRIMARY KEY(id)
850+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
851+ SQL);
852+
853+ Database::query (<<<'SQL'
854+ CREATE TABLE IF NOT EXISTS plugin_grading_electronic_user_session_tracking (
855+ id BIGINT AUTO_INCREMENT NOT NULL,
856+ user_id BIGINT NOT NULL,
857+ session_time VARCHAR(200) NOT NULL,
858+ is_active INT NOT NULL DEFAULT 1,
859+ INDEX idx_pge_user_session_tracking_user_active (user_id, is_active),
860+ PRIMARY KEY(id)
861+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
862+ SQL);
863+
864+ Database::query (<<<'SQL'
865+ CREATE TABLE IF NOT EXISTS plugin_grading_electronic_unregistration_log (
866+ id BIGINT AUTO_INCREMENT NOT NULL,
867+ user_id INT NOT NULL,
868+ course_id INT NOT NULL,
869+ deleted_at_legacy VARCHAR(500) NOT NULL,
870+ last_access_legacy VARCHAR(500) NOT NULL,
871+ INDEX idx_pge_unregistration_user_course (user_id, course_id),
872+ PRIMARY KEY(id)
873+ ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC
874+ SQL);
875+ }
876+
877+
804878 private function getCurrentPluginRegion (): string
805879 {
806880 $ requestUri = $ _SERVER ['REQUEST_URI ' ] ?? '' ;
0 commit comments