-
Notifications
You must be signed in to change notification settings - Fork 4
feat: init sql #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: init sql #496
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,33 @@ | ||
| package upbrella.be.config | ||
|
|
||
| import org.springframework.context.annotation.Configuration | ||
| import org.springframework.context.annotation.Profile | ||
| import org.springframework.stereotype.Component | ||
| import javax.servlet.* | ||
| import javax.servlet.http.HttpServletRequest | ||
| import javax.servlet.http.HttpServletResponse | ||
| import org.springframework.http.HttpMethod | ||
| import org.springframework.web.servlet.config.annotation.CorsRegistry | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer | ||
|
|
||
| @Profile("dev") | ||
| @Component | ||
| class DevCorsConfig : Filter { | ||
|
|
||
| override fun init(filterConfig: FilterConfig) { | ||
| // No initialization needed | ||
| } | ||
|
|
||
| override fun doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain) { | ||
| val request = req as HttpServletRequest | ||
| val response = res as HttpServletResponse | ||
|
|
||
| if (request.getHeader("Origin") != null) { | ||
| if (request.getHeader("Origin").contains("upbrella-dev.site")) { | ||
| response.setHeader("Access-Control-Allow-Origin", "http://upbrella-dev.site") | ||
| } else { | ||
| response.setHeader("Access-Control-Allow-Origin", "http://localhost:3000") | ||
| } | ||
| } else { | ||
| response.setHeader("Access-Control-Allow-Origin", "http://localhost:3000") | ||
| } | ||
|
|
||
| response.setHeader("Access-Control-Allow-Credentials", "true") | ||
| response.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, DELETE, HEAD, OPTIONS") | ||
| response.setHeader("Access-Control-Max-Age", "10") | ||
| response.setHeader("Access-Control-Allow-Headers", | ||
| "Origin, X-Requested-With, Content-Type, Accept, Authorization") | ||
|
|
||
| chain.doFilter(request, response) | ||
| } | ||
|
|
||
| override fun destroy() { | ||
| // No cleanup needed | ||
| @Profile("dev") | ||
| @Configuration | ||
| class DevCorsConfig : WebMvcConfigurer { | ||
|
|
||
| override fun addCorsMappings(registry: CorsRegistry) { | ||
| registry.addMapping("/**") | ||
| .allowedOrigins( | ||
| "http://localhost:3000", | ||
| "https://upbrella-front.vercel.app", | ||
| "https://dev.upbrella.link" | ||
| ) | ||
| .allowedMethods( | ||
| HttpMethod.GET.name, | ||
| HttpMethod.POST.name, | ||
| HttpMethod.PATCH.name, | ||
| HttpMethod.DELETE.name, | ||
| HttpMethod.HEAD.name, | ||
| HttpMethod.OPTIONS.name | ||
| ) | ||
| .allowedHeaders("*") | ||
| .allowCredentials(true) | ||
| .maxAge(3600) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,262 @@ | ||
| -- MySQL dump 10.13 Distrib 8.4.4, for macos15.2 (arm64) | ||
| -- | ||
| -- Host: upbrella-production-db.ccjiaacly7wf.ap-northeast-2.rds.amazonaws.com Database: upbrella_prod | ||
| -- ------------------------------------------------------ | ||
| -- Server version 8.0.40 | ||
|
|
||
| /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
| /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
| /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
| /*!50503 SET NAMES utf8mb4 */; | ||
| /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
| /*!40103 SET TIME_ZONE='+00:00' */; | ||
| /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
| /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
| /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
| /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
| SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN; | ||
| SET @@SESSION.SQL_LOG_BIN= 0; | ||
|
|
||
| -- | ||
| -- GTID state at the beginning of the backup | ||
| -- | ||
|
|
||
| SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ ''; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Eliminate GTID_PURGED assignment for compatibility with managed environments. 🤖 Prompt for AI Agents |
||
|
|
||
| -- | ||
| -- Table structure for table `black_list` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `black_list`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `black_list` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `social_id` bigint DEFAULT NULL, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Unify Also applies to: 240-240 🤖 Prompt for AI Agents |
||
| `blocked_at` datetime DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `business_hour` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `business_hour`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `business_hour` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `store_meta_id` int DEFAULT NULL, | ||
| `date` varchar(45) DEFAULT NULL, | ||
| `open_at` time DEFAULT NULL, | ||
| `close_at` time DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=391 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
|
Comment on lines
+49
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add foreign key and index on INDEX idx_business_hour_store_meta (store_meta_id),
FOREIGN KEY (store_meta_id) REFERENCES store_meta(id)to enforce referential integrity and improve query performance. 🤖 Prompt for AI Agents |
||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `classification` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `classification`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `classification` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `type` varchar(45) DEFAULT NULL, | ||
| `name` varchar(45) DEFAULT NULL, | ||
| `latitude` double DEFAULT NULL, | ||
| `longitude` double DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `condition_report` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `condition_report`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `condition_report` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `content` varchar(401) DEFAULT NULL, | ||
| `etc` varchar(255) DEFAULT NULL, | ||
| `history_id` int DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=523 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `history` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `history`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `history` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `etc` varchar(255) DEFAULT NULL, | ||
| `rented_at` datetime DEFAULT NULL, | ||
| `returned_at` datetime DEFAULT NULL, | ||
| `rent_store_meta_id` int DEFAULT NULL, | ||
| `return_store_meta_id` int DEFAULT NULL, | ||
| `umbrella_id` int DEFAULT NULL, | ||
| `user_id` int DEFAULT NULL, | ||
| `bank` varchar(45) DEFAULT NULL, | ||
| `account_number` varchar(45) DEFAULT NULL, | ||
|
Comment on lines
+107
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Align Also applies to: 241-242 🤖 Prompt for AI Agents |
||
| `refunded_at` datetime DEFAULT NULL, | ||
| `refunded_by` int DEFAULT NULL, | ||
| `paid_at` datetime DEFAULT NULL, | ||
| `paid_by` int DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=523 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `improvement_report` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `improvement_report`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `improvement_report` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `content` varchar(401) DEFAULT NULL, | ||
| `etc` varchar(255) DEFAULT NULL, | ||
| `history_id` int DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=434 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `locker` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `locker`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `locker` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `count` int DEFAULT NULL, | ||
| `secret_key` varchar(2000) DEFAULT NULL, | ||
| `last_access` timestamp NULL DEFAULT NULL, | ||
| `store_meta_id` int DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
|
Comment on lines
+145
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add foreign key and index on INDEX idx_locker_store_meta (store_meta_id),
FOREIGN KEY (store_meta_id) REFERENCES store_meta(id)to ensure referential integrity. 🤖 Prompt for AI Agents |
||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `store_detail` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `store_detail`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `store_detail` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `address` varchar(255) DEFAULT NULL, | ||
| `address_detail` varchar(255) DEFAULT NULL, | ||
| `contact_info` varchar(255) DEFAULT NULL, | ||
| `content` varchar(255) DEFAULT NULL, | ||
| `insta_url` varchar(255) DEFAULT NULL, | ||
| `working_hour` varchar(255) DEFAULT NULL, | ||
| `store_meta_id` int DEFAULT NULL, | ||
| `umbrella_location` varchar(255) DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
|
Comment on lines
+165
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add foreign key and index on INDEX idx_store_detail_store_meta (store_meta_id),
FOREIGN KEY (store_meta_id) REFERENCES store_meta(id)for integrity and performance. 🤖 Prompt for AI Agents |
||
| ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `store_image` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `store_image`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `store_image` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `image_url` varchar(2000) DEFAULT NULL, | ||
| `store_detail_id` int DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=60 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
|
Comment on lines
+181
to
+183
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add foreign key and index on INDEX idx_store_image_detail (store_detail_id),
FOREIGN KEY (store_detail_id) REFERENCES store_detail(id)to maintain referential integrity. 🤖 Prompt for AI Agents |
||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `store_meta` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `store_meta`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `store_meta` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `classification_id` bigint DEFAULT NULL, | ||
| `sub_classification_id` bigint DEFAULT NULL, | ||
| `activated` tinyint DEFAULT NULL, | ||
| `deleted` tinyint DEFAULT NULL, | ||
| `name` varchar(255) DEFAULT NULL, | ||
| `category` varchar(255) DEFAULT NULL, | ||
| `latitude` double DEFAULT NULL, | ||
| `longitude` double DEFAULT NULL, | ||
| `password` varchar(45) DEFAULT NULL, | ||
|
Comment on lines
+195
to
+203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enforce foreign keys, indices, and consistent types on classification references.
to ensure data integrity and improve joins. 🤖 Prompt for AI Agents |
||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `umbrella` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `umbrella`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `umbrella` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `deleted` tinyint DEFAULT NULL, | ||
| `rentable` tinyint DEFAULT NULL, | ||
| `uuid` bigint DEFAULT NULL, | ||
| `store_meta_id` int DEFAULT NULL, | ||
| `created_at` timestamp NULL DEFAULT NULL, | ||
| `etc` varchar(255) DEFAULT NULL, | ||
| `missed` tinyint DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
| ) ENGINE=InnoDB AUTO_INCREMENT=209 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
|
Comment on lines
+220
to
+225
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add foreign key and index on INDEX idx_umbrella_store_meta (store_meta_id),
FOREIGN KEY (store_meta_id) REFERENCES store_meta(id)to enforce referential integrity. 🤖 Prompt for AI Agents |
||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Table structure for table `user` | ||
| -- | ||
|
|
||
| DROP TABLE IF EXISTS `user`; | ||
| /*!40101 SET @saved_cs_client = @@character_set_client */; | ||
| /*!50503 SET character_set_client = utf8mb4 */; | ||
| CREATE TABLE `user` ( | ||
| `id` int NOT NULL AUTO_INCREMENT, | ||
| `admin_status` tinyint DEFAULT NULL, | ||
| `name` varchar(255) DEFAULT NULL, | ||
| `phone_number` varchar(255) DEFAULT NULL, | ||
| `social_id` varchar(500) DEFAULT NULL, | ||
| `bank` varchar(500) DEFAULT NULL, | ||
| `account_number` varchar(500) DEFAULT NULL, | ||
| `email` varchar(500) DEFAULT NULL, | ||
| PRIMARY KEY (`id`) | ||
|
Comment on lines
+238
to
+244
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add unique constraints and indices on key columns. UNIQUE INDEX uq_user_email (email),
UNIQUE INDEX uq_user_social (social_id),
INDEX idx_user_phone (phone_number)to enforce uniqueness and speed up lookups. 🤖 Prompt for AI Agents |
||
| ) ENGINE=InnoDB AUTO_INCREMENT=743 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; | ||
| /*!40101 SET character_set_client = @saved_cs_client */; | ||
|
|
||
| -- | ||
| -- Dumping routines for database 'upbrella_prod' | ||
| -- | ||
| SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN; | ||
| /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
|
||
| /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
| /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
| /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
| /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
| /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
| /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
| /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
|
||
| -- Dump completed on 2025-05-18 21:02:45 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Include database creation and usage statements.
The script drops and recreates tables but doesn’t explicitly ensure the
upbrella_proddatabase exists or switch to it. Add aCREATE DATABASE IF NOT EXISTS upbrella_prod;andUSE upbrella_prod;at the top to guarantee context.🤖 Prompt for AI Agents