Skip to content

Commit 6ed99b9

Browse files
committed
REFACTORED H2DB .sql files
1 parent 6a46776 commit 6ed99b9

14 files changed

+206
-207
lines changed

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html
33

44
# Comma-separated list of active profiles. Can be overridden by a command line switch.
5-
spring.profiles.active=dev
5+
spring.profiles.active=test

src/main/resources/data/h2db/migrations/V0_0_1__basic_structure.sql renamed to src/main/resources/data/h2db/migrations/V0_0_1__SBAT_structure_basic.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- Table structure for table `application_log`
33
--
44

5-
CREATE TABLE `application_log` (
5+
CREATE TABLE `sbat_log` (
66
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
77
`created_by` varchar(255) NOT NULL,
88
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -16,7 +16,7 @@ CREATE TABLE `application_log` (
1616
-- Table structure for table `built_with`
1717
--
1818

19-
CREATE TABLE `built_with` (
19+
CREATE TABLE `sbat_built_with` (
2020
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
2121
`created_by` varchar(255) NOT NULL,
2222
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -32,7 +32,7 @@ CREATE TABLE `built_with` (
3232
-- Table structure for table `application_settings`
3333
--
3434

35-
CREATE TABLE `application_settings` (
35+
CREATE TABLE `sbat_settings` (
3636
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
3737
`created_by` varchar(255) NOT NULL,
3838
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,

src/main/resources/data/h2db/migrations/V0_0_2__audit_structure.sql renamed to src/main/resources/data/h2db/migrations/V0_0_2__SBAT_structure_security.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CREATE TABLE `user` (
2121
-- Table structure for table `permission`
2222
--
2323

24-
CREATE TABLE `permission` (
24+
CREATE TABLE `sbat_auth_permission` (
2525
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
2626
`created_by` varchar(255) NOT NULL,
2727
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -34,7 +34,7 @@ CREATE TABLE `permission` (
3434
-- Table structure for table `role`
3535
--
3636

37-
CREATE TABLE `role` (
37+
CREATE TABLE `sbat_auth_role` (
3838
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
3939
`created_by` varchar(255) NOT NULL,
4040
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -47,31 +47,31 @@ CREATE TABLE `role` (
4747
-- Table structure for table `permission_role`
4848
--
4949

50-
create table permission_role (
50+
create table sbat_auth_permission_role (
5151
role_id bigint not null,
5252
permission_id bigint not null
5353
);
5454

55-
ALTER TABLE permission_role ADD FOREIGN KEY (permission_id) REFERENCES permission(id);
56-
ALTER TABLE permission_role ADD FOREIGN KEY (role_id) REFERENCES role(id);
55+
ALTER TABLE sbat_auth_permission_role ADD FOREIGN KEY (permission_id) REFERENCES sbat_auth_permission(id);
56+
ALTER TABLE sbat_auth_permission_role ADD FOREIGN KEY (role_id) REFERENCES sbat_auth_role(id);
5757

5858
--
5959
-- Table structure for table `role_user`
6060
--
6161

62-
create table role_user (
62+
create table sbat_auth_role_user (
6363
user_id bigint not null,
6464
role_id bigint not null
6565
);
6666

67-
ALTER TABLE role_user ADD FOREIGN KEY (user_id) REFERENCES permission(id);
68-
ALTER TABLE role_user ADD FOREIGN KEY (role_id) REFERENCES role(id);
67+
ALTER TABLE sbat_auth_role_user ADD FOREIGN KEY (user_id) REFERENCES sbat_auth_permission(id);
68+
ALTER TABLE sbat_auth_role_user ADD FOREIGN KEY (role_id) REFERENCES sbat_auth_role(id);
6969

7070
--
7171
-- Table structure for table `verification_token`
7272
--
7373

74-
CREATE TABLE `verification_token` (
74+
CREATE TABLE `sbat_auth_verification_token` (
7575
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
7676
`created_by` varchar(255) NOT NULL,
7777
`created_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -83,18 +83,18 @@ CREATE TABLE `verification_token` (
8383
`user_id` bigint(20) DEFAULT NULL
8484
);
8585

86-
ALTER TABLE verification_token ADD FOREIGN KEY (user_id) REFERENCES user(id);
86+
ALTER TABLE sbat_auth_verification_token ADD FOREIGN KEY (user_id) REFERENCES user(id);
8787

8888
--
8989
-- Table structure for table `refresh_token`
9090
--
9191

92-
CREATE TABLE `refresh_token` (
92+
CREATE TABLE `sbat_auth_refresh_token` (
9393
`id` bigint(20) PRIMARY KEY AUTO_INCREMENT,
9494
`created_date` datetime DEFAULT NULL,
9595
`created_by` varchar(255) NOT NULL,
9696
`last_modified_date` datetime DEFAULT NULL,
9797
`last_modified_by` varchar(255) NOT NULL,
9898
`token` varchar(255) DEFAULT NULL,
9999
`username` varchar(255) DEFAULT NULL
100-
) ;
100+
);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Engine: MySQL
3+
* Version: 0.0.1
4+
* Description: Initial database structure
5+
*/
6+
7+
/*
8+
* Data
9+
*/
10+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Dependency Management','https://maven.apache.org/','Maven','3.5.2','Installation','Installation');
11+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Java™ Platform, Standard Edition Development Kit','http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html','JDK','9.0.1','Installation','Installation');
12+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Framework to ease the bootstrapping and development of new Spring Applications','https://spring.io/projects/spring-boot','Spring Boot ','2.0.4','Installation','Installation');
13+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Open-Source Relational Database Management System','https://www.mysql.com/','MySQL','5.7.21','Installation','Installation');
14+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Version control for database','https://flywaydb.org/','Flyway','6.5.5','Installation','Installation');
15+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.','https://projectlombok.org/','Lombok','1.18.12','Installation','Installation');
16+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Free and Open-Source distributed version control system','https://git-scm.com/','git','2.9.0.windows.1','Installation','Installation');
17+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('API Development Environment (ADE)','https://www.getpostman.com/','Postman','v6.2.3','Installation','Installation');
18+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('API Design, Development, Documentation, Testing & Governance','https://swagger.io/','Swagger','2.7.0','Installation','Installation');
19+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Monitoring system and time series database','https://prometheus.io/','Prometheus','2.3.2','Installation','Installation');
20+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('A hosted continuous integration service used to build and test software projects hosted at GitHub and Bitbucket','https://travis-ci.org/','Travis CI','SaaS','Installation','Installation');
21+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Automated dependency updates','https://dependabot.com/','Dependabot','SaaS','Installation','Installation');
22+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('open-source CSS framework directed at responsive, mobile-first front-end web development','https://getbootstrap.com/','Bootstrap','4.5.2','Installation','Installation');
23+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('An extended table to the integration with some of the most widely used CSS frameworks','https://bootstrap-table.com/','Bootstrap Table','1.17.1','Installation','Installation');
24+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('An automatic table of contents generator, using Bootstrap 3 or 4','https://afeld.github.io/bootstrap-toc/','Bootstrap ToC','','Installation','Installation');
25+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('A dialect for Thymeleaf that allows you to use attributes with a "with" prefix to avoid having long "th:with"-expressions.','https://github.com/Antibrumm/thymeleaf-extras-with-dialect','Thymeleaf With Dialect','3.0.0','Installation','Installation');
26+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('A dialect for Thymeleaf that lets you build layouts and reusable templates in order to improve code reuse.','https://github.com/ultraq/thymeleaf-layout-dialect','Thymeleaf Layout Dialect','2.4.1','Installation','Installation');
27+
INSERT INTO `sbat_built_with` (`description`,`link`,`name`,`version`,`created_by`,`last_modified_by`) VALUES ('Modern server-side Java template engine for both web and standalone environments','https://www.thymeleaf.org/','Thymeleaf','3.0.11','Installation','Installation');
28+
29+
/*
30+
* Data
31+
*/
32+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('applicationName','sbat','Name of the application','Installation','Installation');
33+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('applicationVersion','1.0','Version of the application','Installation','Installation');
34+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('apiVersion','2020-09-20','Version of the API','Installation','Installation');
35+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('releaseVersion','3.1.3','Release version of the API','Installation','Installation');
36+
37+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('postmanEchoBaseUrl','https://postman-echo.com','Postman URL to test the HTTP requests','Installation','Installation');
38+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('postmanEchoGETurl','https://postman-echo.com/get','Postman URL to test the GET request','Installation','Installation');
39+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('postmanEchoPOSTpath','/post','Postman path to test the POST request','Installation','Installation');
40+
41+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('keystoreFileName','redditclone.jks','Java Keystore File Name','Installation','Installation');
42+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('keystoreAlias','redditclone','Alias of the Java Keystore','Installation','Installation');
43+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('keystorePassword','abcd1234','Password of the Java Keystore','Installation','Installation');
44+
45+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('verificationTokenValidity','10','Duration of the verification token validity - In minutes','Installation','Installation');
46+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('jwtExpirationTime','300','Duration of JWT validity - In seconds','Installation','Installation');
47+
48+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('mailFrom','[email protected]','Account verification mail from address','Installation','Installation');
49+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('mailReplyTo','[email protected]','Account verification mail reply to address','Installation','Installation');
50+
INSERT INTO `sbat_settings` (`app_key`,`app_value`,`description`,`created_by`,`last_modified_by`) VALUES ('mailSubject','Spring Boot Application Template','Account verification mail subject','Installation','Installation');
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Engine: MySQL
3+
* Version: 0.0.1
4+
* Description: Initial database structure
5+
*/
6+
7+
/*
8+
* Data - User
9+
*/
10+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','johndoe','Installation','Installation');
11+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','janedoe','Installation','Installation');
12+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','Admin1','Installation','Installation');
13+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','Admin2','Installation','Installation');
14+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','AdminTrainee1','Installation','Installation');
15+
INSERT INTO `user`(`email`,`is_account_non_expired`,`is_account_non_locked`,`is_credentials_non_expired`,`is_enabled`,`password`,`username`,`created_by`,`last_modified_by`)VALUES('[email protected]',1,1,1,1,'$2y$10$TGK.5Z.gLBOBlXjFlXTCme4PQlGneVhYrhLuzosdL8jd3xvuuuvYe','AdminTrainee2','Installation','Installation');
16+
17+
/*
18+
* Data - Permission
19+
*/
20+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('PERSON_CREATE','Installation','Installation');
21+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('PERSON_READ','Installation','Installation');
22+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('PERSON_UPDATE','Installation','Installation');
23+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('PERSON_DELETE','Installation','Installation');
24+
25+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('RBAC_USER_CREATE','Installation','Installation');
26+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('RBAC_USER_READ','Installation','Installation');
27+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('RBAC_USER_UPDATE','Installation','Installation');
28+
INSERT INTO `sbat_auth_permission`(`name`,`created_by`,`last_modified_by`)VALUES('RBAC_USER_DELETE','Installation','Installation');
29+
30+
/*
31+
* Data - Role
32+
*/
33+
INSERT INTO `sbat_auth_role`(`name`,`created_by`,`last_modified_by`)VALUES('ROLE_PERSON','Installation','Installation');
34+
INSERT INTO `sbat_auth_role`(`name`,`created_by`,`last_modified_by`)VALUES('ROLE_ADMIN','Installation','Installation');
35+
INSERT INTO `sbat_auth_role`(`name`,`created_by`,`last_modified_by`)VALUES('ROLE_ADMINTRAINEE','Installation','Installation');
36+
37+
/*
38+
* Data - Permissions for Roles
39+
*/
40+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(1,1); /*PERSON_CREATE - PERSON*/
41+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(2,1); /*PERSON_READ - PERSON*/
42+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(3,1); /*PERSON_UPDATE - PERSON*/
43+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(4,1); /*PERSON_DELETE - PERSON*/
44+
45+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(1,2); /*PERSON_CREATE - ADMIN*/
46+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(2,2); /*PERSON_CREATE - ADMIN*/
47+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(3,2); /*PERSON_CREATE - ADMIN*/
48+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(4,2); /*PERSON_CREATE - ADMIN*/
49+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(5,2); /*COURSE_READ - ADMIN*/
50+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(6,2); /*COURSE_WRITE - ADMIN*/
51+
52+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(2,3); /*PERSON_READ - ADMINTRAINEE*/
53+
INSERT INTO `sbat_auth_permission_role`(`permission_id`,`role_id`)VALUES(5,3); /*PERSON_READ - ADMINTRAINEE*/
54+
55+
/*
56+
* Data - Role of User
57+
*/
58+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(1,1); /* PERSON - johndoe */
59+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(1,2); /* PERSON - janedoe */
60+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(2,3); /* ADMIN - Admin1 */
61+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(2,4); /* ADMIN - Admin2 */
62+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(3,5); /* ADMINTRAINEE - AdminTrainee1 */
63+
INSERT INTO `sbat_auth_role_user`(`role_id`,`user_id`)VALUES(3,6); /* ADMINTRAINEE - AdminTrainee2 */

0 commit comments

Comments
 (0)