Skip to content

Commit

Permalink
V1__init.sql 및 엔티티 클래스 수정 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmw2378 authored Mar 8, 2024
2 parents 7adc5e9 + d404eb9 commit 90a8b11
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Gift extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long giftId;

@Column(nullable = false, length = 50)
private String status;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import java.util.List;
import jakarta.persistence.Table;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.product.entity.Product;

import java.util.List;


@Entity
@Getter
@Table(name = "options")
public class Option extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long optionId;
private Long optionsId;

@Column(nullable = false)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.math.BigDecimal;
import lombok.Getter;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.order.entity.Order;

import java.math.BigDecimal;


@Entity
@Getter
Expand All @@ -33,6 +34,7 @@ public class Payment extends BaseTimeEntity {

@Column(nullable = false, precision = 12, scale = 2)
private BigDecimal deliveryPrice;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "orders_id", nullable = false)
private Order order;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.kakaoshare.backend.domain.base.entity.BaseTimeEntity;
import org.kakaoshare.backend.domain.product.entity.Product;


@Entity
Expand All @@ -27,8 +26,8 @@ public class ProductDescriptionPhoto extends BaseTimeEntity {

@Column
private String photoUrl;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "product_id", nullable = false)
private Product product;

}
80 changes: 56 additions & 24 deletions src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ CREATE TABLE `product`
`type` VARCHAR(50) NOT NULL,
`brand_id` BIGINT NOT NULL,
`product_detail_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`product_id`)
);

Expand All @@ -16,6 +18,8 @@ CREATE TABLE `brand`
`name` VARCHAR(255) NOT NULL,
`icon_photo` VARCHAR(255),
`category_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`brand_id`)
);

Expand All @@ -24,22 +28,28 @@ CREATE TABLE `category`
`category_id` BIGINT NOT NULL,
`parent_id` BIGINT,
`name` VARCHAR(255) NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`category_id`)
);

CREATE TABLE `hashtag`
(
`hashtag_id` BIGINT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`hashtag_id`)
);

CREATE TABLE `option`
CREATE TABLE `options`
(
`option_id` BIGINT NOT NULL,
`options_id` BIGINT NOT NULL,
`name` VARCHAR(255) NOT NULL,
`product_id` BIGINT NOT NULL,
PRIMARY KEY (`option_id`)
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`options_id`)
);

CREATE TABLE `option_detail`
Expand All @@ -49,35 +59,43 @@ CREATE TABLE `option_detail`
`stock_quantity` BIGINT NOT NULL,
`additional_price` DECIMAL(10, 2) NOT NULL,
`photo` VARCHAR(255) NOT NULL,
`option_id` BIGINT NOT NULL,
`options_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`option_detail_id`)
);

CREATE TABLE `product_hashtag`
(
`product_hashtag_id` BIGINT NOT NULL,
`hashtag_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`product_hashtag_id` BIGINT NOT NULL,
`hashtag_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`product_hashtag_id`)
);

CREATE TABLE `wish`
(
`wish_id` BIGINT NOT NULL,
`is_public` BOOLEAN NOT NULL,
`product_id` BIGINT NOT NULL,
`product_detail_id` BIGINT NOT NULL,
`wish_id` BIGINT NOT NULL,
`is_public` BOOLEAN NOT NULL,
`product_id` BIGINT NOT NULL,
`product_detail_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`wish_id`)
);

CREATE TABLE `member`
(
`member_id` BIGINT NOT NULL,
`email` VARCHAR(255) NOT NULL,
`member_id` BIGINT NOT NULL AUTO_INCREMENT,
`gender` VARCHAR(255) NOT NULL,
`name` VARCHAR(255) NOT NULL,
`phone_number` VARCHAR(255) NOT NULL,
`provider_id` VARCHAR(255),
`provider_id` VARCHAR(255) NOT NULL,
`role` VARCHAR(255) NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`member_id`)
);

Expand All @@ -87,19 +105,22 @@ CREATE TABLE `theme`
`photo` VARCHAR(255) NOT NULL,
`description` TEXT NOT NULL,
`product_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`theme_id`)
);

CREATE TABLE `orders`
(
`orders_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`stock_quantity` BIGINT NOT NULL,
`order_number` VARCHAR(50) NOT NULL,
`status` VARCHAR(50) NOT NULL,
`member_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`funding_detail_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`orders_id`)
);

Expand All @@ -110,33 +131,36 @@ CREATE TABLE `payment`
`total_price` DECIMAL(10, 2) NOT NULL,
`purchase_price` DECIMAL(10, 2) NOT NULL,
`delivery_price` DECIMAL(10, 2) NOT NULL,
`created_at` DATETIME NOT NULL,
`orders_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`payment_id`)
);

CREATE TABLE `gift`
(
`gift_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`status` VARCHAR(50) NOT NULL,
`message` VARCHAR(255),
`message_photo` VARCHAR(255),
`product_id` BIGINT NOT NULL,
`orders_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`gift_id`)
);

CREATE TABLE `funding`
(
`funding_id` BIGINT NOT NULL,
`status` VARCHAR(255),
`created_at` DATETIME NOT NULL,
`expired_at` DATETIME NOT NULL,
`goal_amount` DECIMAL(10, 2) NOT NULL,
`accumulate_amount` DECIMAL(10, 2) NOT NULL,
`member_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`expired_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`funding_id`)
);

Expand All @@ -146,6 +170,8 @@ CREATE TABLE `funding_detail`
`amount` DECIMAL(10, 2) NOT NULL,
`rate` DECIMAL(5, 2) NOT NULL,
`funding_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`funding_detail_id`)
);

Expand All @@ -161,21 +187,27 @@ CREATE TABLE `product_detail`
`deliver_description` TEXT NOT NULL,
`billing_notice` TEXT NOT NULL,
`caution` TEXT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`product_detail_id`)
);

CREATE TABLE `product_thumbnail`
(
`product_thumbnail_id` BIGINT NOT NULL,
`product_thumbnail_id` BIGINT NOT NULL,
`thumbnail_url` VARCHAR(255),
`product_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`product_thumbnail_id`)
);

CREATE TABLE `product_description_photo`
(
`photo_id` BIGINT NOT NULL,
`photo_id` BIGINT NOT NULL,
`photo_url` VARCHAR(255),
`product_id` BIGINT NOT NULL,
`product_id` BIGINT NOT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME,
PRIMARY KEY (`photo_id`)
);
);

0 comments on commit 90a8b11

Please sign in to comment.