Update data migrations and removed redundant env

This commit is contained in:
2025-12-30 20:41:14 -05:00
parent dae6d142f2
commit e177723767
4 changed files with 104402 additions and 3775 deletions

View File

@@ -1,12 +0,0 @@
# DATABASE SETTINGS
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ranger_unit_tracker
DB_USERNAME=dev
DB_PASSWORD=dev
# AUTH SETTINGS
AUTH_MODE=mock # mock bypasses authentik
# SERVER SETTINGS
SERVER_PORT=3000

View File

@@ -1,8 +1,8 @@
-- --------------------------------------------------------
-- Host: gs.iceberg-gaming.com
-- Server version: 10.6.5-MariaDB - mariadb.org binary distribution
-- Host: iceberg-gaming.com
-- Server version: 10.6.5-MariaDB-log - mariadb.org binary distribution
-- Server OS: Win64
-- HeidiSQL Version: 12.12.0.7122
-- HeidiSQL Version: 12.13.0.7147
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
@@ -15,11 +15,29 @@
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-- Dumping database structure for ranger_unit_tracker
CREATE DATABASE IF NOT EXISTS `ranger_unit_tracker` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
USE `ranger_unit_tracker`;
-- Dumping database structure for milsim_website_development
CREATE DATABASE IF NOT EXISTS `milsim_website_development` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `milsim_website_development`;
-- Dumping structure for table ranger_unit_tracker.applications
-- Dumping structure for table milsim_website_development.application_comments
CREATE TABLE IF NOT EXISTS `application_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`application_id` int(11) NOT NULL,
`poster_id` int(11) NOT NULL,
`post_time` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`admin_only` tinyint(1) DEFAULT 0,
PRIMARY KEY (`id`),
KEY `poster_id` (`poster_id`),
KEY `application_id` (`application_id`),
CONSTRAINT `application_comments_ibfk_1` FOREIGN KEY (`application_id`) REFERENCES `applications` (`id`),
CONSTRAINT `application_comments_ibfk_2` FOREIGN KEY (`poster_id`) REFERENCES `members` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.applications
CREATE TABLE IF NOT EXISTS `applications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) NOT NULL,
@@ -31,34 +49,20 @@ CREATE TABLE IF NOT EXISTS `applications` (
`denied_at` datetime DEFAULT NULL,
`app_status` varchar(20) GENERATED ALWAYS AS (case when `approved_at` is not null then 'Accepted' when `denied_at` is not null then 'Denied' else 'Pending' end) STORED,
`decision_at` datetime GENERATED ALWAYS AS (coalesce(`approved_at`,`denied_at`)) STORED,
`approved_by` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `member_id` (`member_id`),
KEY `member_id` (`member_id`),
KEY `FK_applications_members` (`approved_by`),
CONSTRAINT `FK_applications_members` FOREIGN KEY (`approved_by`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_app_member` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `chk_json_valid` CHECK (json_valid(`app_data`)),
CONSTRAINT `chk_app_version` CHECK (`app_version` >= 1),
CONSTRAINT `chk_exclusive_decision` CHECK (`approved_at` is null or `denied_at` is null)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.application_comments
CREATE TABLE IF NOT EXISTS `application_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`post_content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`application_id` int(11) NOT NULL,
`poster_id` int(11) NOT NULL,
`post_time` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `poster_id` (`poster_id`),
KEY `application_id` (`application_id`),
CONSTRAINT `application_comments_ibfk_1` FOREIGN KEY (`application_id`) REFERENCES `applications` (`id`),
CONSTRAINT `application_comments_ibfk_2` FOREIGN KEY (`poster_id`) REFERENCES `members` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.arma_maps
-- Dumping structure for table milsim_website_development.arma_maps
CREATE TABLE IF NOT EXISTS `arma_maps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`map` varchar(50) DEFAULT NULL,
@@ -68,11 +72,11 @@ CREATE TABLE IF NOT EXISTS `arma_maps` (
`workshop_id` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `map` (`map`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Arma3 Maps';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Arma3 Maps';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.awards
-- Dumping structure for table milsim_website_development.awards
CREATE TABLE IF NOT EXISTS `awards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` longtext DEFAULT NULL,
@@ -87,38 +91,44 @@ CREATE TABLE IF NOT EXISTS `awards` (
`deleted_at` datetime(3) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_awards_deleted` (`deleted`)
) ENGINE=InnoDB AUTO_INCREMENT=81 DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Awards for the unit.';
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Awards for the unit.';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.calendar_events
-- Dumping structure for table milsim_website_development.calendar_events
CREATE TABLE IF NOT EXISTS `calendar_events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`start` datetime NOT NULL,
`end` datetime NOT NULL,
`location` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`color` char(7) COLLATE utf8mb4_unicode_ci NOT NULL,
`color` char(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#000000',
`description` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`creator` int(11) DEFAULT NULL,
`cancelled` tinyint(1) DEFAULT 0,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`full_day` tinyint(4) DEFAULT NULL,
`guilded_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`guilded_channel_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_creator` (`creator`),
CONSTRAINT `fk_creator` FOREIGN KEY (`creator`) REFERENCES `members` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CONSTRAINT `FK_calendar_events_members` FOREIGN KEY (`creator`) REFERENCES `members` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3346 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.calendar_events_signups
-- Dumping structure for table milsim_website_development.calendar_events_signups
CREATE TABLE IF NOT EXISTS `calendar_events_signups` (
`member_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`status` enum('not_attending','attending','maybe') COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`guilded_member_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`guilded_event_id` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`member_id`,`event_id`),
UNIQUE KEY `guilded_member_id_guilded_event_id` (`guilded_member_id`,`guilded_event_id`),
KEY `fk_signup_event` (`event_id`),
CONSTRAINT `fk_signup_event` FOREIGN KEY (`event_id`) REFERENCES `calendar_events` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_signup_member` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON DELETE CASCADE
@@ -126,69 +136,32 @@ CREATE TABLE IF NOT EXISTS `calendar_events_signups` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.courses
CREATE TABLE IF NOT EXISTS `courses` (
-- Dumping structure for table milsim_website_development.course_attendee_roles
CREATE TABLE IF NOT EXISTS `course_attendee_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`short_name` varchar(10) NOT NULL,
`category` varchar(100) NOT NULL,
`description` varchar(1000) DEFAULT NULL,
`image_url` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
`prereq_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `shortName` (`short_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.courses_single
CREATE TABLE IF NOT EXISTS `courses_single` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`short_name` varchar(10) NOT NULL,
`category` varchar(100) NOT NULL,
`description` varchar(1000) DEFAULT NULL,
`image_url` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
`prereq_id` int(11) DEFAULT NULL,
`require_qual` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `shortName` (`short_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.courses_sme
CREATE TABLE IF NOT EXISTS `courses_sme` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` int(11) NOT NULL DEFAULT 0,
`member_id` int(11) NOT NULL DEFAULT 0,
`name` varchar(50) DEFAULT NULL,
`description` text DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
KEY `fk_course_sme_course_id` (`course_id`),
KEY `fk_course_sme_member_id` (`member_id`),
CONSTRAINT `fk_course_sme_course_id` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_course_sme_member_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
UNIQUE KEY `type` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='Changed from course_attendee_type to event_attendee_type';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.course_attendees
-- Dumping structure for table milsim_website_development.course_attendees
CREATE TABLE IF NOT EXISTS `course_attendees` (
`passed` tinyint(1) DEFAULT 0,
`passed_bookwork` tinyint(1) NOT NULL DEFAULT 0,
`passed_qual` tinyint(1) NOT NULL DEFAULT 0,
`attendee_id` int(11) NOT NULL,
`course_event_id` int(11) NOT NULL,
`attendee_role_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`remarks` text DEFAULT NULL,
`expired` tinyint(4) NOT NULL DEFAULT 0,
`expired_reason` varchar(50) NOT NULL DEFAULT '0',
PRIMARY KEY (`attendee_id`,`course_event_id`) USING BTREE,
KEY `courseInstanceId` (`course_event_id`) USING BTREE,
KEY `fk_CourseInstancesMembers_CoureseAttendeeType_id` (`attendee_role_id`) USING BTREE,
@@ -199,21 +172,7 @@ CREATE TABLE IF NOT EXISTS `course_attendees` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.course_attendee_roles
CREATE TABLE IF NOT EXISTS `course_attendee_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
`description` text DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `type` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COMMENT='Changed from course_attendee_type to event_attendee_type';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.course_category
-- Dumping structure for table milsim_website_development.course_category
CREATE TABLE IF NOT EXISTS `course_category` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL
@@ -221,27 +180,34 @@ CREATE TABLE IF NOT EXISTS `course_category` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.course_events
-- Dumping structure for table milsim_website_development.course_events
CREATE TABLE IF NOT EXISTS `course_events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` int(11) DEFAULT NULL,
`event_type` int(11) DEFAULT NULL,
`event_date` datetime NOT NULL,
`guilded_event_id` int(11) DEFAULT NULL,
`guilded_event_id` varchar(50) DEFAULT NULL,
`guilded_report_id` varchar(50) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
`report_url` varchar(2048) DEFAULT NULL,
`remarks` text DEFAULT NULL,
`created_by` int(11) DEFAULT NULL,
`hasBookwork` tinyint(4) DEFAULT NULL,
`hasQual` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_course_events_event_type_id` (`event_type`) USING BTREE,
KEY `courseId` (`course_id`) USING BTREE,
KEY `fk_course_events_created_by` (`created_by`),
CONSTRAINT `fk_coures_events_course_id` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_course_events_created_by` FOREIGN KEY (`created_by`) REFERENCES `members` (`id`),
CONSTRAINT `fk_course_events_event_type_id` FOREIGN KEY (`event_type`) REFERENCES `event_types` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.course_qualified_trainers
-- Dumping structure for table milsim_website_development.course_qualified_trainers
CREATE TABLE IF NOT EXISTS `course_qualified_trainers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT NULL,
@@ -258,11 +224,48 @@ CREATE TABLE IF NOT EXISTS `course_qualified_trainers` (
CONSTRAINT `fk_coures_qualified_trainers_coures_events_id` FOREIGN KEY (`instance_qualified_id`) REFERENCES `course_events` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_coures_qualified_trainers_coures_id` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_coures_qualified_trainers_mebers_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='Contains a linked group of qualified trainers';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contains a linked group of qualified trainers';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.event_types
-- Dumping structure for table milsim_website_development.courses
CREATE TABLE IF NOT EXISTS `courses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`short_name` varchar(10) NOT NULL,
`category` varchar(100) NOT NULL,
`description` varchar(1000) DEFAULT NULL,
`image_url` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
`prereq_id` int(11) DEFAULT NULL,
`hasBookwork` tinyint(1) NOT NULL DEFAULT 0,
`hasQual` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `shortName` (`short_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.courses_sme
CREATE TABLE IF NOT EXISTS `courses_sme` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`course_id` int(11) NOT NULL DEFAULT 0,
`member_id` int(11) NOT NULL DEFAULT 0,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `fk_course_sme_course_id` (`course_id`),
KEY `fk_course_sme_member_id` (`member_id`),
CONSTRAINT `fk_course_sme_course_id` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_course_sme_member_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.event_types
CREATE TABLE IF NOT EXISTS `event_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`event_type` varchar(100) DEFAULT NULL,
@@ -273,7 +276,7 @@ CREATE TABLE IF NOT EXISTS `event_types` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.guilded_events
-- Dumping structure for table milsim_website_development.guilded_events
CREATE TABLE IF NOT EXISTS `guilded_events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`channel_id` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -287,29 +290,52 @@ CREATE TABLE IF NOT EXISTS `guilded_events` (
`url` varchar(2048) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `calendar_id_event_id` (`channel_id`,`event_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3267 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.leave_of_absences
-- Dumping structure for table milsim_website_development.leave_of_absences
CREATE TABLE IF NOT EXISTS `leave_of_absences` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT NULL,
`filed_date` datetime NOT NULL,
`start_date` datetime NOT NULL,
`end_date` datetime NOT NULL,
`reason` text DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`filed_date` datetime NOT NULL COMMENT 'Date that the LOA was filed',
`start_date` datetime NOT NULL COMMENT 'Date that the LOA should Start',
`end_date` datetime NOT NULL COMMENT 'Date that the LOA should End',
`extended_till` datetime DEFAULT NULL,
`type_id` int(11) DEFAULT NULL,
`reason` text DEFAULT NULL COMMENT 'Reason a person has put in the LOA',
`created_by_id` int(11) DEFAULT NULL,
`deleted` tinyint(4) NOT NULL DEFAULT 0,
`expired` tinyint(4) DEFAULT NULL COMMENT 'If a LOA is Expired or not',
`closed_by` int(11) DEFAULT NULL COMMENT 'Who Closed the LOA if it was manually Closed',
`ended_at` date DEFAULT NULL,
`closed` tinyint(4) DEFAULT NULL COMMENT 'If a LOA was closed early or ',
`created_at` datetime NOT NULL DEFAULT current_timestamp() COMMENT 'Database Record Creation Date',
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'Database Record Modified Date',
PRIMARY KEY (`id`),
KEY `fk_leave_of_absesnse_members_id` (`member_id`) USING BTREE,
KEY `FK_leave_of_absences_leave_of_absences_types` (`type_id`),
KEY `c` (`created_by_id`),
CONSTRAINT `FK_leave_of_absences_leave_of_absences_types` FOREIGN KEY (`type_id`) REFERENCES `leave_of_absences_types` (`id`) ON UPDATE CASCADE,
CONSTRAINT `c` FOREIGN KEY (`created_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_leave_of_absesnse_members_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members
-- Dumping structure for table milsim_website_development.leave_of_absences_types
CREATE TABLE IF NOT EXISTS `leave_of_absences_types` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`max_length_days` int(11) NOT NULL DEFAULT 0,
`extendable` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.members
CREATE TABLE IF NOT EXISTS `members` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
@@ -329,18 +355,21 @@ CREATE TABLE IF NOT EXISTS `members` (
`remarks` text DEFAULT NULL,
`authentik_sub` varchar(255) DEFAULT NULL,
`authentik_issuer` varchar(255) DEFAULT NULL,
`state` enum('guest','applicant','member','retired','banned','denied') NOT NULL DEFAULT 'guest',
`state` enum('guest','applicant','member','retired','banned','denied') NOT NULL DEFAULT 'member',
`displayName` varchar(50) DEFAULT NULL,
`last_activity` datetime DEFAULT NULL,
`last_login` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
UNIQUE KEY `steamId64` (`steam_id_64`) USING BTREE,
UNIQUE KEY `discordId` (`discord_id`) USING BTREE,
UNIQUE KEY `guilded_id` (`guilded_id`),
UNIQUE KEY `uk_authentik_identity` (`authentik_issuer`,`authentik_sub`)
) ENGINE=InnoDB AUTO_INCREMENT=191 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=3349 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members_awards
-- Dumping structure for table milsim_website_development.members_awards
CREATE TABLE IF NOT EXISTS `members_awards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT NULL,
@@ -357,7 +386,7 @@ CREATE TABLE IF NOT EXISTS `members_awards` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members_qualifications
-- Dumping structure for table milsim_website_development.members_qualifications
CREATE TABLE IF NOT EXISTS `members_qualifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT 0,
@@ -375,24 +404,32 @@ CREATE TABLE IF NOT EXISTS `members_qualifications` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members_ranks
-- Dumping structure for table milsim_website_development.members_ranks
CREATE TABLE IF NOT EXISTS `members_ranks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT NULL,
`rank_id` int(11) DEFAULT NULL,
`event_date` datetime DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`member_id` int(11) NOT NULL,
`rank_id` int(11) NOT NULL,
`authorized_by_id` int(11) DEFAULT NULL,
`created_by_id` int(11) DEFAULT NULL,
`reason` varchar(50) DEFAULT NULL,
`start_date` datetime NOT NULL DEFAULT current_timestamp(),
`end_date` datetime DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `fk_members_ranks_members_id` (`member_id`),
KEY `fk_members_ranks_rank_id` (`rank_id`),
CONSTRAINT `fk_members_ranks_members_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
KEY `FK_members_ranks_members_2` (`authorized_by_id`),
KEY `FK_members_ranks_members_3` (`created_by_id`),
CONSTRAINT `FK_members_ranks_members` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_ranks_members_2` FOREIGN KEY (`authorized_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_ranks_members_3` FOREIGN KEY (`created_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_members_ranks_rank_id` FOREIGN KEY (`rank_id`) REFERENCES `ranks` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=210 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members_roles
-- Dumping structure for table milsim_website_development.members_roles
CREATE TABLE IF NOT EXISTS `members_roles` (
`member_id` int(11) NOT NULL,
`role_id` int(11) NOT NULL,
@@ -404,27 +441,57 @@ CREATE TABLE IF NOT EXISTS `members_roles` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.members_statuses
-- Dumping structure for table milsim_website_development.members_statuses
CREATE TABLE IF NOT EXISTS `members_statuses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) DEFAULT NULL,
`status_id` int(11) DEFAULT NULL,
`reason_id` int(11) DEFAULT NULL,
`event_date` datetime DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`member_id` int(11) NOT NULL,
`status_id` int(11) NOT NULL,
`authorized_by_id` int(11) DEFAULT NULL,
`created_by_id` int(11) DEFAULT NULL,
`reason` varchar(50) DEFAULT NULL,
`start_date` datetime NOT NULL DEFAULT current_timestamp(),
`end_date` datetime DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `fk_members_statuses_status_id` (`status_id`),
KEY `fk_members_statuses_member_id` (`member_id`),
KEY `fk_members_statuses_statuses_reasons_id` (`reason_id`) USING BTREE,
CONSTRAINT `fk_members_statuses_member_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_members_statuses_status_id` FOREIGN KEY (`status_id`) REFERENCES `statuses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `members_statuses_FK` FOREIGN KEY (`reason_id`) REFERENCES `statuses_reasons` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=207 DEFAULT CHARSET=utf8mb4;
KEY `FK_members_statuses_ranger_unit_tracker.members` (`authorized_by_id`),
KEY `FK_members_statuses_ranger_unit_tracker.members_2` (`created_by_id`),
CONSTRAINT `FK_members_statuses_members` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_statuses_ranger_unit_tracker.members` FOREIGN KEY (`authorized_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_statuses_ranger_unit_tracker.members_2` FOREIGN KEY (`created_by_id`) REFERENCES `members` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `fk_members_statuses_status_id` FOREIGN KEY (`status_id`) REFERENCES `statuses` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.mission_attendee_roles
-- Dumping structure for table milsim_website_development.members_unit
CREATE TABLE IF NOT EXISTS `members_unit` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`member_id` int(11) NOT NULL,
`unit_id` int(11) NOT NULL,
`authorized_by_id` int(11) NOT NULL,
`created_by_id` int(11) NOT NULL,
`reason` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`start_date` datetime NOT NULL DEFAULT current_timestamp(),
`end_date` datetime DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `FK_members_unit_units` (`unit_id`),
KEY `FK_members_unit_members` (`member_id`),
KEY `FK_members_unit_members_2` (`authorized_by_id`),
KEY `FK_members_unit_members_3` (`created_by_id`),
CONSTRAINT `FK_members_unit_members` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_unit_members_2` FOREIGN KEY (`authorized_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_unit_members_3` FOREIGN KEY (`created_by_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_members_unit_units` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=96 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.mission_attendee_roles
CREATE TABLE IF NOT EXISTS `mission_attendee_roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
@@ -433,11 +500,30 @@ CREATE TABLE IF NOT EXISTS `mission_attendee_roles` (
`deleted` tinyint(4) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `role_name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.mission_events
-- Dumping structure for table milsim_website_development.mission_event_attendees
CREATE TABLE IF NOT EXISTS `mission_event_attendees` (
`id` int(11) DEFAULT NULL,
`member_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`member_role_id` int(11) DEFAULT NULL,
`event_type` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`member_id`,`event_id`) USING BTREE,
KEY `fk_mission_event_attendees_role_id` (`member_role_id`),
KEY `fk_mission_event_events_id` (`event_id`),
CONSTRAINT `fk_member_event_member_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_attendees_role_id` FOREIGN KEY (`member_role_id`) REFERENCES `mission_attendee_roles` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_events_id` FOREIGN KEY (`event_id`) REFERENCES `mission_events` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.mission_events
CREATE TABLE IF NOT EXISTS `mission_events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`event_type_id` int(11) NOT NULL,
@@ -459,30 +545,11 @@ CREATE TABLE IF NOT EXISTS `mission_events` (
CONSTRAINT `fk_events_author_id` FOREIGN KEY (`author_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_map_id` FOREIGN KEY (`map_id`) REFERENCES `arma_maps` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_type_id` FOREIGN KEY (`event_type_id`) REFERENCES `event_types` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.mission_event_attendees
CREATE TABLE IF NOT EXISTS `mission_event_attendees` (
`id` int(11) DEFAULT NULL,
`member_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`member_role_id` int(11) DEFAULT NULL,
`event_type` int(11) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`member_id`,`event_id`) USING BTREE,
KEY `fk_mission_event_attendees_role_id` (`member_role_id`),
KEY `fk_mission_event_events_id` (`event_id`),
CONSTRAINT `fk_member_event_member_id` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_attendees_role_id` FOREIGN KEY (`member_role_id`) REFERENCES `mission_attendee_roles` (`id`) ON UPDATE CASCADE,
CONSTRAINT `fk_mission_event_events_id` FOREIGN KEY (`event_id`) REFERENCES `mission_events` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.qualifications
-- Dumping structure for table milsim_website_development.qualifications
CREATE TABLE IF NOT EXISTS `qualifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
@@ -497,11 +564,11 @@ CREATE TABLE IF NOT EXISTS `qualifications` (
`deleted` tinytext DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=99 DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Member Qualifications for the unit.';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contains a list of Member Qualifications for the unit.';
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.ranks
-- Dumping structure for table milsim_website_development.ranks
CREATE TABLE IF NOT EXISTS `ranks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` longtext DEFAULT NULL,
@@ -513,17 +580,19 @@ CREATE TABLE IF NOT EXISTS `ranks` (
`updated_at` datetime(3) NOT NULL,
`deleted` tinyint(1) NOT NULL DEFAULT 0,
`deleted_at` datetime(3) DEFAULT NULL,
`discord_role_id` varchar(50) DEFAULT NULL,
`teamspeak_role_id` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `shortName` (`short_name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.roles
-- Dumping structure for table milsim_website_development.roles
CREATE TABLE IF NOT EXISTS `roles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`color` varchar(9) COLLATE utf8mb4_unicode_ci NOT NULL,
`color` varchar(9) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#000000',
`description` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
@@ -531,33 +600,57 @@ CREATE TABLE IF NOT EXISTS `roles` (
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.statuses
CREATE TABLE IF NOT EXISTS `statuses` (
-- Dumping structure for table milsim_website_development.site_config
CREATE TABLE IF NOT EXISTS `site_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
`discord_guild_id` int(11) DEFAULT NULL,
`application_unit_on_accept` int(11) DEFAULT NULL,
`application_rank_on_accept` int(11) DEFAULT NULL,
`application_status_on_accept` int(11) DEFAULT NULL,
`loa_consecutive_gap_days` int(11) DEFAULT 0,
`loa_consecutive_count` int(11) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
KEY `FK_site_config_units` (`application_unit_on_accept`),
KEY `FK_site_config_ranks` (`application_rank_on_accept`),
KEY `FK_site_config_statuses` (`application_status_on_accept`),
CONSTRAINT `FK_site_config_ranks` FOREIGN KEY (`application_rank_on_accept`) REFERENCES `ranks` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_site_config_statuses` FOREIGN KEY (`application_status_on_accept`) REFERENCES `statuses` (`id`) ON UPDATE CASCADE,
CONSTRAINT `FK_site_config_units` FOREIGN KEY (`application_unit_on_accept`) REFERENCES `units` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Data exporting was unselected.
-- Dumping structure for table ranger_unit_tracker.statuses_reasons
CREATE TABLE IF NOT EXISTS `statuses_reasons` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Contains a list of Reasons that a Status Change occured. This helps determine Promotions, Demotions, Transfers, Joins, Leaves.';
-- Dumping structure for procedure milsim_website_development.sp_accept_new_recruit_validation
DELIMITER //
//
DELIMITER ;
-- Data exporting was unselected.
-- Dumping structure for procedure milsim_website_development.sp_GetCalendarEventSignups
DELIMITER //
//
DELIMITER ;
-- Dumping structure for table ranger_unit_tracker.status_change_requests
-- Dumping structure for procedure milsim_website_development.sp_manual_update_report
DELIMITER //
//
DELIMITER ;
-- Dumping structure for procedure milsim_website_development.sp_update_member_rank
DELIMITER //
//
DELIMITER ;
-- Dumping structure for procedure milsim_website_development.sp_update_member_status
DELIMITER //
//
DELIMITER ;
-- Dumping structure for procedure milsim_website_development.sp_update_member_unit
DELIMITER //
//
DELIMITER ;
-- Dumping structure for table milsim_website_development.status_change_requests
CREATE TABLE IF NOT EXISTS `status_change_requests` (
`id` int(11) NOT NULL,
`member_id` int(11) DEFAULT NULL,
@@ -586,7 +679,58 @@ CREATE TABLE IF NOT EXISTS `status_change_requests` (
-- Data exporting was unselected.
-- Dumping structure for view ranger_unit_tracker.view_member_rank_status_all
-- Dumping structure for table milsim_website_development.statuses
CREATE TABLE IF NOT EXISTS `statuses` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.statuses_reasons
CREATE TABLE IF NOT EXISTS `statuses_reasons` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` datetime DEFAULT current_timestamp(),
`updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`deleted` tinyint(4) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Contains a list of Reasons that a Status Change occured. This helps determine Promotions, Demotions, Transfers, Joins, Leaves.';
-- Data exporting was unselected.
-- Dumping structure for table milsim_website_development.units
CREATE TABLE IF NOT EXISTS `units` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`type` enum('Company','Status','External') DEFAULT NULL,
`is_internal` tinyint(4) NOT NULL,
`description` text DEFAULT NULL,
`active` tinyint(4) NOT NULL DEFAULT 1,
`color` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
-- Data exporting was unselected.
-- Dumping structure for view milsim_website_development.view_member_latest_info
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `view_member_latest_info` (
`member_id` INT(11) NOT NULL,
`member_name` VARCHAR(1) NOT NULL COLLATE 'utf8mb4_general_ci',
`rank` LONGTEXT NULL COLLATE 'utf8mb4_general_ci',
`rank_date` DATETIME NULL,
`status` VARCHAR(1) NULL COLLATE 'utf8mb4_general_ci',
`status_date` DATETIME NULL
);
-- Dumping structure for view milsim_website_development.view_member_rank_status_all
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `view_member_rank_status_all` (
`member_id` INT(11) NOT NULL,
@@ -597,9 +741,46 @@ CREATE TABLE `view_member_rank_status_all` (
`status_date` DATETIME NULL
);
-- Dumping structure for view milsim_website_development.view_member_rank_unit_status_latest
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `view_member_rank_unit_status_latest` (
`member_id` INT(11) NOT NULL,
`member_name` VARCHAR(1) NOT NULL COLLATE 'utf8mb4_general_ci',
`displayName` VARCHAR(1) NULL COLLATE 'utf8mb4_general_ci',
`rank` LONGTEXT NULL COLLATE 'utf8mb4_general_ci',
`rank_date` DATETIME NULL,
`status` VARCHAR(1) NULL COLLATE 'utf8mb4_general_ci',
`status_date` DATETIME NULL,
`unit` VARCHAR(1) NULL COLLATE 'utf8mb4_general_ci',
`unit_date` DATETIME NULL,
`loa_until` DATE NULL
);
-- Dumping structure for view milsim_website_development.view_member_settings
-- Creating temporary table to overcome VIEW dependency errors
CREATE TABLE `view_member_settings` (
`id` INT(11) NOT NULL,
`displayName` VARCHAR(1) NULL COLLATE 'utf8mb4_general_ci'
);
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `view_member_latest_info`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_member_latest_info` AS select `m`.`id` AS `member_id`,`m`.`name` AS `member_name`,`r`.`name` AS `rank`,`mr`.`start_date` AS `rank_date`,`s`.`name` AS `status`,`ms`.`start_date` AS `status_date` from ((((`milsim_website_development`.`members` `m` left join (select `mr`.`id` AS `id`,`mr`.`member_id` AS `member_id`,`mr`.`rank_id` AS `rank_id`,`mr`.`start_date` AS `start_date`,`mr`.`created_at` AS `created_at`,`mr`.`updated_at` AS `updated_at` from ((`milsim_website_development`.`members_ranks` `mr` join (select `milsim_website_development`.`members_ranks`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_ranks`.`start_date`) AS `max_date` from `milsim_website_development`.`members_ranks` group by `milsim_website_development`.`members_ranks`.`member_id`) `lr` on(`lr`.`member_id` = `mr`.`member_id` and `lr`.`max_date` = `mr`.`start_date`)) join (select `milsim_website_development`.`members_ranks`.`member_id` AS `member_id`,`milsim_website_development`.`members_ranks`.`start_date` AS `start_date`,max(`milsim_website_development`.`members_ranks`.`id`) AS `max_id` from `milsim_website_development`.`members_ranks` group by `milsim_website_development`.`members_ranks`.`member_id`,`milsim_website_development`.`members_ranks`.`start_date`) `lr2` on(`lr2`.`member_id` = `mr`.`member_id` and `lr2`.`start_date` = `mr`.`start_date` and `lr2`.`max_id` = `mr`.`id`))) `mr` on(`mr`.`member_id` = `m`.`id`)) left join `milsim_website_development`.`ranks` `r` on(`r`.`id` = `mr`.`rank_id`)) left join (select `ms`.`id` AS `id`,`ms`.`member_id` AS `member_id`,`ms`.`status_id` AS `status_id`,`ms`.`start_date` AS `start_date`,`ms`.`created_at` AS `created_at`,`ms`.`updated_at` AS `updated_at` from ((`milsim_website_development`.`members_statuses` `ms` join (select `milsim_website_development`.`members_statuses`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_statuses`.`start_date`) AS `max_date` from `milsim_website_development`.`members_statuses` group by `milsim_website_development`.`members_statuses`.`member_id`) `ls` on(`ls`.`member_id` = `ms`.`member_id` and `ls`.`max_date` = `ms`.`start_date`)) join (select `milsim_website_development`.`members_statuses`.`member_id` AS `member_id`,`milsim_website_development`.`members_statuses`.`start_date` AS `start_date`,max(`milsim_website_development`.`members_statuses`.`id`) AS `max_id` from `milsim_website_development`.`members_statuses` group by `milsim_website_development`.`members_statuses`.`member_id`,`milsim_website_development`.`members_statuses`.`start_date`) `ls2` on(`ls2`.`member_id` = `ms`.`member_id` and `ls2`.`start_date` = `ms`.`start_date` and `ls2`.`max_id` = `ms`.`id`))) `ms` on(`ms`.`member_id` = `m`.`id`)) left join `milsim_website_development`.`statuses` `s` on(`s`.`id` = `ms`.`status_id`))
;
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `view_member_rank_status_all`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_member_rank_status_all` AS select `ranger_unit_tracker`.`members`.`id` AS `member_id`,`ranger_unit_tracker`.`members`.`name` AS `member_name`,`ranger_unit_tracker`.`ranks`.`name` AS `rank`,`members_ranks`.`event_date` AS `rank_date`,`ranger_unit_tracker`.`statuses`.`name` AS `status`,`members_statuses`.`event_date` AS `status_date` from ((((`ranger_unit_tracker`.`members` left join (select `mr`.`id` AS `id`,`mr`.`member_id` AS `member_id`,`mr`.`rank_id` AS `rank_id`,`mr`.`event_date` AS `event_date`,`mr`.`created_at` AS `created_at`,`mr`.`updated_at` AS `updated_at` from (`ranger_unit_tracker`.`members_ranks` `mr` join (select `ranger_unit_tracker`.`members_ranks`.`member_id` AS `member_id`,max(`ranger_unit_tracker`.`members_ranks`.`event_date`) AS `max_rank_date` from `ranger_unit_tracker`.`members_ranks` group by `ranger_unit_tracker`.`members_ranks`.`member_id`) `latest_ranks` on(`mr`.`member_id` = `latest_ranks`.`member_id` and `mr`.`event_date` = `latest_ranks`.`max_rank_date`))) `members_ranks` on(`ranger_unit_tracker`.`members`.`id` = `members_ranks`.`member_id`)) left join (select `ms`.`id` AS `id`,`ms`.`member_id` AS `member_id`,`ms`.`status_id` AS `status_id`,`ms`.`event_date` AS `event_date`,`ms`.`created_at` AS `created_at`,`ms`.`updated_at` AS `updated_at` from (`ranger_unit_tracker`.`members_statuses` `ms` join (select `ranger_unit_tracker`.`members_statuses`.`member_id` AS `member_id`,max(`ranger_unit_tracker`.`members_statuses`.`event_date`) AS `max_status_date` from `ranger_unit_tracker`.`members_statuses` group by `ranger_unit_tracker`.`members_statuses`.`member_id`) `latest_statuses` on(`ms`.`member_id` = `latest_statuses`.`member_id` and `ms`.`event_date` = `latest_statuses`.`max_status_date`))) `members_statuses` on(`ranger_unit_tracker`.`members`.`id` = `members_statuses`.`member_id`)) left join `ranger_unit_tracker`.`ranks` on(`members_ranks`.`rank_id` = `ranger_unit_tracker`.`ranks`.`id`)) left join `ranger_unit_tracker`.`statuses` on(`members_statuses`.`status_id` = `ranger_unit_tracker`.`statuses`.`id`))
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_member_rank_status_all` AS select `milsim_website_development`.`members`.`id` AS `member_id`,`milsim_website_development`.`members`.`name` AS `member_name`,`milsim_website_development`.`ranks`.`name` AS `rank`,`members_ranks`.`start_date` AS `rank_date`,`milsim_website_development`.`statuses`.`name` AS `status`,`members_statuses`.`start_date` AS `status_date` from ((((`milsim_website_development`.`members` left join (select `mr`.`id` AS `id`,`mr`.`member_id` AS `member_id`,`mr`.`rank_id` AS `rank_id`,`mr`.`start_date` AS `start_date`,`mr`.`created_at` AS `created_at`,`mr`.`updated_at` AS `updated_at` from (`milsim_website_development`.`members_ranks` `mr` join (select `milsim_website_development`.`members_ranks`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_ranks`.`start_date`) AS `max_rank_date` from `milsim_website_development`.`members_ranks` group by `milsim_website_development`.`members_ranks`.`member_id`) `latest_ranks` on(`mr`.`member_id` = `latest_ranks`.`member_id` and `mr`.`start_date` = `latest_ranks`.`max_rank_date`))) `members_ranks` on(`milsim_website_development`.`members`.`id` = `members_ranks`.`member_id`)) left join (select `ms`.`id` AS `id`,`ms`.`member_id` AS `member_id`,`ms`.`status_id` AS `status_id`,`ms`.`start_date` AS `start_date`,`ms`.`created_at` AS `created_at`,`ms`.`updated_at` AS `updated_at` from (`milsim_website_development`.`members_statuses` `ms` join (select `milsim_website_development`.`members_statuses`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_statuses`.`start_date`) AS `max_status_date` from `milsim_website_development`.`members_statuses` group by `milsim_website_development`.`members_statuses`.`member_id`) `latest_statuses` on(`ms`.`member_id` = `latest_statuses`.`member_id` and `ms`.`start_date` = `latest_statuses`.`max_status_date`))) `members_statuses` on(`milsim_website_development`.`members`.`id` = `members_statuses`.`member_id`)) left join `milsim_website_development`.`ranks` on(`members_ranks`.`rank_id` = `milsim_website_development`.`ranks`.`id`)) left join `milsim_website_development`.`statuses` on(`members_statuses`.`status_id` = `milsim_website_development`.`statuses`.`id`))
;
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `view_member_rank_unit_status_latest`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_member_rank_unit_status_latest` AS select `m`.`id` AS `member_id`,`m`.`name` AS `member_name`,`m`.`displayName` AS `displayName`,`r`.`name` AS `rank`,`mr`.`start_date` AS `rank_date`,`s`.`name` AS `status`,`ms`.`start_date` AS `status_date`,`u`.`name` AS `unit`,`mu`.`start_date` AS `unit_date`,`loa`.`loa_until` AS `loa_until` from (((((((`milsim_website_development`.`members` `m` left join (select `mr`.`member_id` AS `member_id`,`mr`.`rank_id` AS `rank_id`,`mr`.`start_date` AS `start_date` from (`milsim_website_development`.`members_ranks` `mr` join (select `milsim_website_development`.`members_ranks`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_ranks`.`start_date`) AS `max_start_date` from `milsim_website_development`.`members_ranks` group by `milsim_website_development`.`members_ranks`.`member_id`) `latest` on(`mr`.`member_id` = `latest`.`member_id` and `mr`.`start_date` = `latest`.`max_start_date`))) `mr` on(`m`.`id` = `mr`.`member_id`)) left join `milsim_website_development`.`ranks` `r` on(`mr`.`rank_id` = `r`.`id`)) left join (select `ms`.`member_id` AS `member_id`,`ms`.`status_id` AS `status_id`,`ms`.`start_date` AS `start_date` from (`milsim_website_development`.`members_statuses` `ms` join (select `milsim_website_development`.`members_statuses`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_statuses`.`start_date`) AS `max_start_date` from `milsim_website_development`.`members_statuses` group by `milsim_website_development`.`members_statuses`.`member_id`) `latest` on(`ms`.`member_id` = `latest`.`member_id` and `ms`.`start_date` = `latest`.`max_start_date`))) `ms` on(`m`.`id` = `ms`.`member_id`)) left join `milsim_website_development`.`statuses` `s` on(`ms`.`status_id` = `s`.`id`)) left join (select `mu`.`member_id` AS `member_id`,`mu`.`unit_id` AS `unit_id`,`mu`.`start_date` AS `start_date` from (`milsim_website_development`.`members_unit` `mu` join (select `milsim_website_development`.`members_unit`.`member_id` AS `member_id`,max(`milsim_website_development`.`members_unit`.`start_date`) AS `max_start_date` from `milsim_website_development`.`members_unit` group by `milsim_website_development`.`members_unit`.`member_id`) `latest` on(`mu`.`member_id` = `latest`.`member_id` and `mu`.`start_date` = `latest`.`max_start_date`))) `mu` on(`m`.`id` = `mu`.`member_id`)) left join `milsim_website_development`.`units` `u` on(`mu`.`unit_id` = `u`.`id`)) left join (select `l`.`member_id` AS `member_id`,max(greatest(cast(`l`.`end_date` as date),cast(coalesce(`l`.`extended_till`,`l`.`end_date`) as date))) AS `loa_until` from `milsim_website_development`.`leave_of_absences` `l` where `l`.`deleted` = 0 and (`l`.`closed` is null or `l`.`closed` = 0) and (`l`.`expired` is null or `l`.`expired` = 0) and cast(`l`.`start_date` as date) <= curdate() and (cast(`l`.`end_date` as date) >= curdate() or cast(`l`.`extended_till` as date) >= curdate()) group by `l`.`member_id`) `loa` on(`loa`.`member_id` = `m`.`id`))
;
-- Removing temporary table and create final VIEW structure
DROP TABLE IF EXISTS `view_member_settings`;
CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `view_member_settings` AS select `m`.`id` AS `id`,`m`.`displayName` AS `displayName` from `members` `m`
;
/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;

File diff suppressed because it is too large Load Diff