diff --git a/rest-api/src/main/java/life/qbic/data_download/rest/security/jpa/setup-user-tables.sql b/rest-api/src/main/java/life/qbic/data_download/rest/security/jpa/setup-user-tables.sql new file mode 100644 index 0000000..3f0f42d --- /dev/null +++ b/rest-api/src/main/java/life/qbic/data_download/rest/security/jpa/setup-user-tables.sql @@ -0,0 +1,65 @@ +USE data_management; +CREATE TABLE `ngs_measurements` +( + `measurement_id` varchar(255) NOT NULL, + `measurementCode` varchar(255) DEFAULT NULL, + `projectId` varchar(255) DEFAULT NULL, + PRIMARY KEY (`measurement_id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; + +CREATE TABLE `personal_access_tokens` +( + `id` int(11) NOT NULL, + `tokenValueEncrypted` varchar(255) DEFAULT NULL, + `creationDate` datetime(6) DEFAULT NULL, + `duration` decimal(21, 0) DEFAULT NULL, + `userId` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; + +CREATE TABLE `proteomics_measurement` +( + `measurement_id` varchar(255) NOT NULL, + `measurementCode` varchar(255) DEFAULT NULL, + `projectId` varchar(255) DEFAULT NULL, + PRIMARY KEY (`measurement_id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; + +CREATE TABLE `roles` +( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `description` varchar(255) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; + +CREATE TABLE `users` +( + `id` varchar(255) NOT NULL, + `active` bit(1) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; + +CREATE TABLE `user_role` +( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `roleId` bigint(20) NOT NULL, + `userId` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + KEY `FK_userId` (`userId`), + KEY `FK_roleId` (`roleId`), + CONSTRAINT `FK_roleId` FOREIGN KEY (`roleId`) REFERENCES `roles` (`id`), + CONSTRAINT `FK_userId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci; diff --git a/rest-api/src/main/resources/application.properties b/rest-api/src/main/resources/application.properties index 054d2dd..fb44ee4 100644 --- a/rest-api/src/main/resources/application.properties +++ b/rest-api/src/main/resources/application.properties @@ -26,6 +26,10 @@ logging.level.org.hibernate=error logging.file.path=${LOG_PATH:./logs} logging.file.name=${logging.file.path}/${LOG_FILE_NAME:server.log} +# set to true to enable ddl changes in the database +spring.jpa.generate-ddl=false +spring.jpa.hibernate.ddl-auto=none + ### Default datasource spring.datasource.url=${USER_DB_URL:localhost} spring.datasource.driver-class-name=${USER_DB_DRIVER:com.mysql.cj.jdbc.Driver}