diff --git a/src/main/java/org/example/commerce_site/application/order/OrderService.java b/src/main/java/org/example/commerce_site/application/order/OrderService.java index 17bb085..aabd0c7 100644 --- a/src/main/java/org/example/commerce_site/application/order/OrderService.java +++ b/src/main/java/org/example/commerce_site/application/order/OrderService.java @@ -1,6 +1,8 @@ package org.example.commerce_site.application.order; import org.example.commerce_site.application.order.dto.OrderRequestDto; +import org.example.commerce_site.common.exception.CustomException; +import org.example.commerce_site.common.exception.ErrorCode; import org.example.commerce_site.domain.Order; import org.example.commerce_site.infrastructure.order.OrderRepository; import org.springframework.stereotype.Service; @@ -17,4 +19,11 @@ public class OrderService { public Order createOrder(OrderRequestDto.Create dto) { return orderRepository.save(OrderRequestDto.Create.toEntity(dto)); } + + @Transactional(readOnly = true) + public Order getOrder(Long orderId, Long userId) { + return orderRepository.findByIdAndUserId(orderId, userId).orElseThrow( + () -> new CustomException(ErrorCode.ORDER_NOT_FOUND) + ); + } } diff --git a/src/main/java/org/example/commerce_site/application/payment/PaymentFacade.java b/src/main/java/org/example/commerce_site/application/payment/PaymentFacade.java new file mode 100644 index 0000000..ad6064d --- /dev/null +++ b/src/main/java/org/example/commerce_site/application/payment/PaymentFacade.java @@ -0,0 +1,24 @@ +package org.example.commerce_site.application.payment; + +import org.example.commerce_site.application.order.OrderService; +import org.example.commerce_site.application.payment.dto.PaymentRequestDto; +import org.example.commerce_site.application.user.UserService; +import org.example.commerce_site.domain.Order; +import org.example.commerce_site.domain.User; +import org.springframework.stereotype.Service; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PaymentFacade { + private final PaymentService paymentService; + private final UserService userService; + private final OrderService orderService; + + public void createPayment(PaymentRequestDto.Create dto) { + User user = userService.getUser(dto.getUserAuthId()); + Order order = orderService.getOrder(dto.getOrderId(), user.getId()); + paymentService.create(PaymentRequestDto.Create.toEntity(dto, order, user.getId())); + } +} diff --git a/src/main/java/org/example/commerce_site/application/payment/PaymentService.java b/src/main/java/org/example/commerce_site/application/payment/PaymentService.java new file mode 100644 index 0000000..2d5af6c --- /dev/null +++ b/src/main/java/org/example/commerce_site/application/payment/PaymentService.java @@ -0,0 +1,19 @@ +package org.example.commerce_site.application.payment; + +import org.example.commerce_site.domain.Payment; +import org.example.commerce_site.infrastructure.payment.PaymentRepository; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class PaymentService { + private final PaymentRepository paymentRepository; + + @Transactional + public Payment create(Payment order) { + return paymentRepository.save(order); + } +} diff --git a/src/main/java/org/example/commerce_site/application/payment/dto/PaymentRequestDto.java b/src/main/java/org/example/commerce_site/application/payment/dto/PaymentRequestDto.java new file mode 100644 index 0000000..6ee94c3 --- /dev/null +++ b/src/main/java/org/example/commerce_site/application/payment/dto/PaymentRequestDto.java @@ -0,0 +1,32 @@ +package org.example.commerce_site.application.payment.dto; + +import java.math.BigDecimal; + +import org.example.commerce_site.attribute.PaymentMethod; +import org.example.commerce_site.attribute.PaymentStatus; +import org.example.commerce_site.domain.Order; +import org.example.commerce_site.domain.Payment; + +import lombok.Builder; +import lombok.Getter; + +public class PaymentRequestDto { + @Builder + @Getter + public static class Create { + public PaymentMethod paymentMethod; + public BigDecimal amount; + public String userAuthId; + public Long orderId; + + public static Payment toEntity(Create dto, Order order, Long userId) { + return Payment.builder() + .amount(dto.getAmount()) + .status(PaymentStatus.PENDING) + .paymentMethod(dto.getPaymentMethod()) + .userId(userId) + .order(order) + .build(); + } + } +} diff --git a/src/main/java/org/example/commerce_site/application/user/UserService.java b/src/main/java/org/example/commerce_site/application/user/UserService.java index e9d153b..f6fdb83 100644 --- a/src/main/java/org/example/commerce_site/application/user/UserService.java +++ b/src/main/java/org/example/commerce_site/application/user/UserService.java @@ -24,6 +24,13 @@ public User getUser(Long userId) { ); } + @Transactional(readOnly = true) + public User getUser(String userAuthId) { + return userRepository.findByAuthId(userAuthId).orElseThrow( + () -> new CustomException(ErrorCode.USER_NOT_FOUND) + ); + } + @Transactional public void create(UserRequestDto.Create dto) { userRepository.save(UserRequestDto.Create.toEntity(dto)); diff --git a/src/main/java/org/example/commerce_site/attribute/PaymentMethod.java b/src/main/java/org/example/commerce_site/attribute/PaymentMethod.java new file mode 100644 index 0000000..fc3d962 --- /dev/null +++ b/src/main/java/org/example/commerce_site/attribute/PaymentMethod.java @@ -0,0 +1,7 @@ +package org.example.commerce_site.attribute; + +public enum PaymentMethod { + CARD, + CASH, + POINT +} diff --git a/src/main/java/org/example/commerce_site/attribute/PaymentStatus.java b/src/main/java/org/example/commerce_site/attribute/PaymentStatus.java new file mode 100644 index 0000000..d2f40d0 --- /dev/null +++ b/src/main/java/org/example/commerce_site/attribute/PaymentStatus.java @@ -0,0 +1,9 @@ +package org.example.commerce_site.attribute; + +public enum PaymentStatus { + PENDING, // 결제 대기 중 + COMPLETED, // 결제 완료 + FAILED, // 결제 실패 + CANCELLED, // 결제 취소 + REFUNDED; // 환불 처리 완료 +} diff --git a/src/main/java/org/example/commerce_site/common/exception/ErrorCode.java b/src/main/java/org/example/commerce_site/common/exception/ErrorCode.java index c291bf4..40a323a 100644 --- a/src/main/java/org/example/commerce_site/common/exception/ErrorCode.java +++ b/src/main/java/org/example/commerce_site/common/exception/ErrorCode.java @@ -28,6 +28,9 @@ public enum ErrorCode { CREATE_KEYCLOAK_USER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "인가 서버 유저 등록에 실패했습니다."), ADD_USER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 500, "API 서버 유저 등록에 실패했습니다."), + //order + ORDER_NOT_FOUND(HttpStatus.NOT_FOUND, 404, "주문 정보를 찾을 수 없습니다."), + //partner PARTNER_NOT_FOUND(HttpStatus.NOT_FOUND, 404, "파트너 회원 정보를 찾을 수 없습니다."), diff --git a/src/main/java/org/example/commerce_site/config/AuthExcludeProperties.java b/src/main/java/org/example/commerce_site/config/AuthExcludeProperties.java new file mode 100644 index 0000000..6229932 --- /dev/null +++ b/src/main/java/org/example/commerce_site/config/AuthExcludeProperties.java @@ -0,0 +1,18 @@ +package org.example.commerce_site.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Component +@ConfigurationProperties(prefix = "auth.exclude") +public class AuthExcludeProperties { + private String[] post; + private String[] get; + private String[] web; +} + diff --git a/src/main/java/org/example/commerce_site/config/OpenApiConfig.java b/src/main/java/org/example/commerce_site/config/OpenApiConfig.java index f97ba23..3aedafe 100644 --- a/src/main/java/org/example/commerce_site/config/OpenApiConfig.java +++ b/src/main/java/org/example/commerce_site/config/OpenApiConfig.java @@ -8,8 +8,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; @Configuration @@ -28,14 +31,23 @@ public OpenAPI openAPI() { .version("1.0") .description("Commerce Site API Documentation"); + Components components = new Components(); + components.addSecuritySchemes("bearerAuth", new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT") + .description("Enter your Bearer token in the format: **Bearer <token>**")); + return new OpenAPI() + .components(components) + .addSecurityItem(new SecurityRequirement().addList("bearerAuth")) .info(info) .servers(serverList); } @Bean public GroupedOpenApi userOpenApi() { - String[] paths = {"/user/**"}; + String[] paths = {"/users/**"}; return GroupedOpenApi.builder().group("USER API").pathsToMatch(paths).build(); } @@ -47,7 +59,7 @@ public GroupedOpenApi partnerOpenApi() { @Bean public GroupedOpenApi productOpenApi() { - String[] paths = {"/product/**"}; + String[] paths = {"/products/**"}; return GroupedOpenApi.builder().group("PRODUCT API").pathsToMatch(paths).build(); } @@ -65,13 +77,19 @@ public GroupedOpenApi addressOpenApi() { @Bean public GroupedOpenApi cartOpenApi() { - String[] paths = {"/cart/**"}; + String[] paths = {"/carts/**"}; return GroupedOpenApi.builder().group("CART API").pathsToMatch(paths).build(); } @Bean public GroupedOpenApi orderOpenApi() { - String[] paths = {"/order/**"}; + String[] paths = {"/orders/**"}; return GroupedOpenApi.builder().group("ORDER API").pathsToMatch(paths).build(); } + + @Bean + public GroupedOpenApi paymentsOpenApi() { + String[] paths = {"/payments/**"}; + return GroupedOpenApi.builder().group("PAYMENT API").pathsToMatch(paths).build(); + } } diff --git a/src/main/java/org/example/commerce_site/config/SecurityConfig.java b/src/main/java/org/example/commerce_site/config/SecurityConfig.java index bdb95d5..ba37f42 100644 --- a/src/main/java/org/example/commerce_site/config/SecurityConfig.java +++ b/src/main/java/org/example/commerce_site/config/SecurityConfig.java @@ -1,5 +1,6 @@ package org.example.commerce_site.config; +import org.example.commerce_site.config.filter.UserIdFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -11,15 +12,22 @@ import org.springframework.security.core.session.SessionRegistryImpl; import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter; import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; @Configuration @EnableWebSecurity public class SecurityConfig { - private static final String[] AUTH_EXCLUDE_POST_API_LIST = {"/user/keycloak/webhook"}; - private static final String[] AUTH_EXCLUDE_GET_API_LIST = {"/auth/**"}; - private static final String[] AUTH_EXCLUDE_WEB_LIST = {"/swagger-ui/**", "/api-docs/**"}; + // private static final String[] AUTH_EXCLUDE_POST_API_LIST = {"/users/keycloak/webhook"}; + // private static final String[] AUTH_EXCLUDE_GET_API_LIST = {"/auth/**"}; + // private static final String[] AUTH_EXCLUDE_WEB_LIST = {"/swagger-ui/**", "/api-docs/**"}; + + private final AuthExcludeProperties authExcludeProperties; + + public SecurityConfig(AuthExcludeProperties authExcludeProperties) { + this.authExcludeProperties = authExcludeProperties; + } @Bean protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { @@ -34,15 +42,16 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .csrf(AbstractHttpConfigurer::disable) .cors(Customizer.withDefaults()) .authorizeHttpRequests(requests -> requests - .requestMatchers(HttpMethod.POST, AUTH_EXCLUDE_POST_API_LIST).permitAll() - .requestMatchers(HttpMethod.GET, AUTH_EXCLUDE_GET_API_LIST).permitAll() - .requestMatchers(AUTH_EXCLUDE_WEB_LIST).permitAll() + .requestMatchers(HttpMethod.POST, authExcludeProperties.getPost()).permitAll() + .requestMatchers(HttpMethod.GET, authExcludeProperties.getGet()).permitAll() + .requestMatchers(authExcludeProperties.getWeb()).permitAll() .anyRequest().authenticated() ) + .addFilterAfter(new UserIdFilter(authExcludeProperties), UsernamePasswordAuthenticationFilter.class) .oauth2ResourceServer( oauth2 -> oauth2.jwt(jwt -> jwt.jwtAuthenticationConverter(jwtAuthenticationConverter))) .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)); - + return http.build(); } } diff --git a/src/main/java/org/example/commerce_site/config/filter/UserIdFilter.java b/src/main/java/org/example/commerce_site/config/filter/UserIdFilter.java new file mode 100644 index 0000000..7244a30 --- /dev/null +++ b/src/main/java/org/example/commerce_site/config/filter/UserIdFilter.java @@ -0,0 +1,53 @@ +package org.example.commerce_site.config.filter; + +import java.io.IOException; +import java.util.Arrays; +import java.util.stream.Stream; + +import org.example.commerce_site.config.AuthExcludeProperties; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Component +public class UserIdFilter extends OncePerRequestFilter { + private final AuthExcludeProperties excludeProperties; + + public UserIdFilter(AuthExcludeProperties excludeProperties) { + this.excludeProperties = excludeProperties; + } + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + + String requestURI = request.getRequestURI(); + boolean isExcluded = Stream.of(excludeProperties.getPost(), excludeProperties.getGet(), + excludeProperties.getWeb()) + .flatMap(Arrays::stream) + .anyMatch(path -> requestURI.equals(path) || requestURI.startsWith(path.replace("**", ""))); + + if (isExcluded) { + filterChain.doFilter(request, response); + return; + } + + var authentication = SecurityContextHolder.getContext().getAuthentication(); + + if (authentication != null && authentication.isAuthenticated()) { + String userId = ((JwtAuthenticationToken)authentication).getToken().getSubject(); + request.setAttribute("userId", userId); + } + + filterChain.doFilter(request, response); + } + +} diff --git a/src/main/java/org/example/commerce_site/domain/Payment.java b/src/main/java/org/example/commerce_site/domain/Payment.java new file mode 100644 index 0000000..b64cced --- /dev/null +++ b/src/main/java/org/example/commerce_site/domain/Payment.java @@ -0,0 +1,40 @@ +package org.example.commerce_site.domain; + +import java.math.BigDecimal; + +import org.example.commerce_site.attribute.PaymentMethod; +import org.example.commerce_site.attribute.PaymentStatus; +import org.example.commerce_site.common.domain.BaseTimeEntity; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "payments") +public class Payment extends BaseTimeEntity { + private Long userId; + + @OneToOne + @JoinColumn(name = "order_id") + private Order order; + + @Enumerated(EnumType.STRING) + private PaymentMethod paymentMethod; + + @Enumerated(EnumType.STRING) + private PaymentStatus status; + + private BigDecimal amount; +} diff --git a/src/main/java/org/example/commerce_site/infrastructure/order/OrderDetailBulkRepository.java b/src/main/java/org/example/commerce_site/infrastructure/order/OrderDetailBulkRepository.java index cb6bb4d..be6b1b0 100644 --- a/src/main/java/org/example/commerce_site/infrastructure/order/OrderDetailBulkRepository.java +++ b/src/main/java/org/example/commerce_site/infrastructure/order/OrderDetailBulkRepository.java @@ -4,7 +4,6 @@ import java.sql.Timestamp; import java.util.List; -import org.example.commerce_site.application.order.dto.OrderDetailResponseDto; import org.example.commerce_site.domain.OrderDetail; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; diff --git a/src/main/java/org/example/commerce_site/infrastructure/order/OrderRepository.java b/src/main/java/org/example/commerce_site/infrastructure/order/OrderRepository.java index cf17109..0450a94 100644 --- a/src/main/java/org/example/commerce_site/infrastructure/order/OrderRepository.java +++ b/src/main/java/org/example/commerce_site/infrastructure/order/OrderRepository.java @@ -1,9 +1,12 @@ package org.example.commerce_site.infrastructure.order; +import java.util.Optional; + import org.example.commerce_site.domain.Order; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface OrderRepository extends JpaRepository { + Optional findByIdAndUserId(Long orderId, Long userId); } diff --git a/src/main/java/org/example/commerce_site/infrastructure/payment/PaymentRepository.java b/src/main/java/org/example/commerce_site/infrastructure/payment/PaymentRepository.java new file mode 100644 index 0000000..b063505 --- /dev/null +++ b/src/main/java/org/example/commerce_site/infrastructure/payment/PaymentRepository.java @@ -0,0 +1,9 @@ +package org.example.commerce_site.infrastructure.payment; + +import org.example.commerce_site.domain.Payment; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PaymentRepository extends JpaRepository { +} diff --git a/src/main/java/org/example/commerce_site/infrastructure/user/UserRepository.java b/src/main/java/org/example/commerce_site/infrastructure/user/UserRepository.java index c635924..0892191 100644 --- a/src/main/java/org/example/commerce_site/infrastructure/user/UserRepository.java +++ b/src/main/java/org/example/commerce_site/infrastructure/user/UserRepository.java @@ -8,5 +8,5 @@ @Repository public interface UserRepository extends JpaRepository { - Optional findByEmail(String email); + Optional findByAuthId(String userAuthId); } diff --git a/src/main/java/org/example/commerce_site/representation/order/OrderController.java b/src/main/java/org/example/commerce_site/representation/order/OrderController.java index 944aa8c..ba51796 100644 --- a/src/main/java/org/example/commerce_site/representation/order/OrderController.java +++ b/src/main/java/org/example/commerce_site/representation/order/OrderController.java @@ -13,7 +13,7 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/order") +@RequestMapping("/orders") public class OrderController { private final OrderFacade orderFacade; diff --git a/src/main/java/org/example/commerce_site/representation/payment/PaymentController.java b/src/main/java/org/example/commerce_site/representation/payment/PaymentController.java new file mode 100644 index 0000000..03eb551 --- /dev/null +++ b/src/main/java/org/example/commerce_site/representation/payment/PaymentController.java @@ -0,0 +1,32 @@ +package org.example.commerce_site.representation.payment; + +import org.example.commerce_site.application.payment.PaymentFacade; +import org.example.commerce_site.common.response.ApiSuccessResponse; +import org.example.commerce_site.representation.payment.dto.PaymentRequest; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@RestController +@RequiredArgsConstructor +@RequestMapping("/payments") +public class PaymentController { + private final PaymentFacade paymentFacade; + + @PostMapping("/{order_id}") + public ApiSuccessResponse createPayment( + @PathVariable("order_id") Long orderId, + @RequestAttribute("userId") String userAuthId, + @RequestBody PaymentRequest.Create request + ) { + paymentFacade.createPayment(PaymentRequest.Create.toDto(request, orderId, userAuthId)); + return ApiSuccessResponse.success(); + } +} diff --git a/src/main/java/org/example/commerce_site/representation/payment/dto/PaymentRequest.java b/src/main/java/org/example/commerce_site/representation/payment/dto/PaymentRequest.java new file mode 100644 index 0000000..fa29500 --- /dev/null +++ b/src/main/java/org/example/commerce_site/representation/payment/dto/PaymentRequest.java @@ -0,0 +1,29 @@ +package org.example.commerce_site.representation.payment.dto; + +import java.math.BigDecimal; + +import org.example.commerce_site.application.payment.dto.PaymentRequestDto; +import org.example.commerce_site.attribute.PaymentMethod; + +import jakarta.validation.constraints.NotNull; +import lombok.Getter; + +public class PaymentRequest { + @Getter + public static class Create { + @NotNull(message = "payment method can not NULL") + public PaymentMethod paymentMethod; + + @NotNull(message = "amount can not NULL") + public BigDecimal amount; + + public static PaymentRequestDto.Create toDto(PaymentRequest.Create create, Long orderId, String userAuthId) { + return PaymentRequestDto.Create.builder() + .paymentMethod(create.paymentMethod) + .amount(create.amount) + .orderId(orderId) + .userAuthId(userAuthId) + .build(); + } + } +} diff --git a/src/main/java/org/example/commerce_site/representation/user/UserController.java b/src/main/java/org/example/commerce_site/representation/user/UserController.java index 22dcaa0..d0afbae 100644 --- a/src/main/java/org/example/commerce_site/representation/user/UserController.java +++ b/src/main/java/org/example/commerce_site/representation/user/UserController.java @@ -4,7 +4,6 @@ import org.example.commerce_site.config.KeycloakProperties; import org.example.commerce_site.representation.user.request.UserRequest; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f12be8a..e880b7e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -56,4 +56,13 @@ oauth: uri: redirect: http://localhost:8080/auth/callback token: http://localhost:9090/realms/oauth2/protocol/openid-connect/token - api-key: klzx98c7vadq34tkdjfhgq3#@$adfg!dfax-n-4c \ No newline at end of file + api-key: klzx98c7vadq34tkdjfhgq3#@$adfg!dfax-n-4c +auth: + exclude: + post: + - /users/keycloak/webhook + get: + - /auth/** + web: + - /swagger-ui/** + - /api-docs/** \ No newline at end of file diff --git a/src/main/resources/db/migration/mysql/V1.5__update_payment_table.sql b/src/main/resources/db/migration/mysql/V1.5__update_payment_table.sql new file mode 100644 index 0000000..a2ac2e5 --- /dev/null +++ b/src/main/resources/db/migration/mysql/V1.5__update_payment_table.sql @@ -0,0 +1,12 @@ +ALTER TABLE `ecommerce_site`.`payments` +DROP +COLUMN `payment_date`; + +ALTER TABLE `ecommerce_site`.`payments` + ADD COLUMN `created_at` DATETIME NOT NULL; + +ALTER TABLE `ecommerce_site`.`payments` + ADD COLUMN `updated_at` DATETIME NULL; + +ALTER TABLE `ecommerce_site`.`payments` + ADD COLUMN `user_id` BIGINT NOT NULL; \ No newline at end of file