Skip to content

Commit

Permalink
Merge pull request #1 from CodingNomads/add-ddl-script-for-dev-and-te…
Browse files Browse the repository at this point in the history
…st-RELEASE-1.0.0

inital commit for ddl scripts
  • Loading branch information
rdesmond authored Nov 30, 2021
2 parents dc6e738 + 03599ec commit 12419a4
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/resources/contact_table_ddl_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE `contact` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`user_id` int NOT NULL COMMENT 'Foreign Key',
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`telephone` varchar(255) NOT NULL,
`forum_username` varchar(255) NOT NULL,
`slack_username` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`),
CONSTRAINT `fk_user_id_contact` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Contact information for user';
102 changes: 102 additions & 0 deletions src/main/resources/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
-- user
DROP TABLE IF EXISTS `kotlin.backend.db`.`user`;

CREATE TABLE `kotlin.backend.db`.`user` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'PK',
`role_code` int(10) UNSIGNED NOT NULL COMMENT 'The user role',
`status_code` int(10) NOT NULL,
`timezone_offset` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='List of users';

-- mentor_student_lookup
DROP TABLE IF EXISTS `kotlin.backend.db`.`mentor_student_lookup`;

CREATE TABLE `kotlin.backend.db`.`mentor_student_lookup` (
`id` INT NOT NULL AUTO_INCREMENT COMMENT 'PK',
`mentor_id` int NOT NULL COMMENT 'Foreign Key',
`student_id` int NOT NULL COMMENT 'Foreign Key',
`status_code` int NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `mentor_id_idx` (`mentor_id`),
KEY `student_id_idx` (`student_id`),
CONSTRAINT `fk_user_id_mentor` FOREIGN KEY (`mentor_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_user_id_student` FOREIGN KEY (`student_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Mentor and student status';

-- security
DROP TABLE IF EXISTS `kotlin.backend.db`.`security`;

CREATE TABLE `kotlin.backend.db`.`security` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`user_id` int NOT NULL COMMENT 'Foreign Key',
`username` varchar(255) NOT NULL,
`password_hash` varchar(255) NOT NULL,
`is_admin` tinyint NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`),
CONSTRAINT `fk_user_id_security` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Username, password, admin status';

-- contact
DROP TABLE IF EXISTS `kotlin.backend.db`.`contact`;

CREATE TABLE `kotlin.backend.db`.`contact` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`user_id` int NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`telephone` varchar(255) NOT NULL,
`forum_username` varchar(255) NOT NULL,
`slack_username` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`),
CONSTRAINT `fk_user_id_contact` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='User contact and account information';

-- support_log
DROP TABLE IF EXISTS `kotlin.backend.db`.`support_log`;

CREATE TABLE `kotlin.backend.db`.`support_log` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`mentor_student_lookup_id` int NOT NULL,
`log` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `mentor_student_lookup_id_idx` (`mentor_student_lookup_id`),
CONSTRAINT `fk_mentor_student_lookup_id_support_log` FOREIGN KEY (`mentor_student_lookup_id`) REFERENCES `mentor_student_lookup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Log for tracking mentorship program';

-- role
DROP TABLE IF EXISTS `kotlin.backend.db`.`role`;

CREATE TABLE `kotlin.backend.db`.`role` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`code` int NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Classification of user role with code';

-- status
DROP TABLE IS EXISTS `kotlin.backend.db`.`status`;

CREATE TABLE `kotlin.backend.db`.`status` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`code` int NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Classification of mentorship status';

11 changes: 11 additions & 0 deletions src/main/resources/mentor_student_lookup_table_ddl_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE `mentor_student_lookup` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`mentor_id` int NOT NULL COMMENT 'Foreign Key',
`student_id` int NOT NULL COMMENT 'Foreign Key',
`status_code` int NOT NULL,
PRIMARY KEY (`id`),
KEY `mentor_id_idx` (`mentor_id`),
KEY `student_id_idx` (`student_id`),
CONSTRAINT `fk_user_id_mentor` FOREIGN KEY (`mentor_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_user_id_student` FOREIGN KEY (`student_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Mentor and student status';
10 changes: 10 additions & 0 deletions src/main/resources/security_ddl_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE `security` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`user_id` int NOT NULL COMMENT 'Foreign Key',
`username` varchar(255) NOT NULL,
`password_hash` varchar(255) NOT NULL,
`is_admin` tinyint NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id_idx` (`user_id`),
CONSTRAINT `fk_user_id_security` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Username, password, admin status';
8 changes: 8 additions & 0 deletions src/main/resources/support _log_ddl_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE `support_log` (
`id` int NOT NULL AUTO_INCREMENT COMMENT 'PK',
`mentor_student_lookup_id` int NOT NULL COMMENT 'Foreign Key',
`log` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `mentor_student_lookup_id_idx` (`mentor_student_lookup_id`),
CONSTRAINT `fk_mentor_student_lookup_id_support_log` FOREIGN KEY (`mentor_student_lookup_id`) REFERENCES `mentor_student_lookup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='Support log for mentorship';
9 changes: 9 additions & 0 deletions src/main/resources/user_table_ddl_script.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP TABLE IF EXISTS `kotlin.backend.db`.`user`;

CREATE TABLE `kotlin.backend.db`.`user` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'PK',
`role_code` int(10) UNSIGNED NOT NULL COMMENT 'The user role',
`status_code` int(10) NOT NULL,
`timezone_offset` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=compressed COMMENT='List of users';

0 comments on commit 12419a4

Please sign in to comment.