From f90baaec270650cf66c39b9cd11d920daf4f8110 Mon Sep 17 00:00:00 2001 From: chaerim Date: Wed, 8 Nov 2023 17:39:16 +0900 Subject: [PATCH] feat(notification): add PushToken entity --- .../wemeet/domain/notification/PushToken.java | 38 +++++++++++++++++++ .../notification/PushTokenRepository.java | 7 ++++ .../V2311081752__create_push_token.sql | 9 +++++ 3 files changed, 54 insertions(+) create mode 100644 src/main/java/com/e2i/wemeet/domain/notification/PushToken.java create mode 100644 src/main/java/com/e2i/wemeet/domain/notification/PushTokenRepository.java create mode 100644 src/main/resources/db/migration/V2311081752__create_push_token.sql diff --git a/src/main/java/com/e2i/wemeet/domain/notification/PushToken.java b/src/main/java/com/e2i/wemeet/domain/notification/PushToken.java new file mode 100644 index 00000000..7567ca97 --- /dev/null +++ b/src/main/java/com/e2i/wemeet/domain/notification/PushToken.java @@ -0,0 +1,38 @@ +package com.e2i.wemeet.domain.notification; + +import com.e2i.wemeet.domain.base.BaseTimeEntity; +import com.e2i.wemeet.domain.member.Member; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "PUSH_TOKEN") +@Entity +public class PushToken extends BaseTimeEntity { + + @Id + private String token; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "member_id") + private Member member; + + @Builder + public PushToken(String token, Member member) { + this.token = token; + this.member = member; + } + + private void setMember(final Member member) { + this.member = member; + } +} diff --git a/src/main/java/com/e2i/wemeet/domain/notification/PushTokenRepository.java b/src/main/java/com/e2i/wemeet/domain/notification/PushTokenRepository.java new file mode 100644 index 00000000..ddffc74f --- /dev/null +++ b/src/main/java/com/e2i/wemeet/domain/notification/PushTokenRepository.java @@ -0,0 +1,7 @@ +package com.e2i.wemeet.domain.notification; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PushTokenRepository extends JpaRepository { + +} \ No newline at end of file diff --git a/src/main/resources/db/migration/V2311081752__create_push_token.sql b/src/main/resources/db/migration/V2311081752__create_push_token.sql new file mode 100644 index 00000000..179a3b7c --- /dev/null +++ b/src/main/resources/db/migration/V2311081752__create_push_token.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `push_token` +( + `token` varchar(100) NOT NULL, + `member_id` bigint, + PRIMARY KEY (`token`), + FOREIGN KEY (`member_id`) REFERENCES member (`member_id`) ON DELETE CASCADE + ) + ENGINE = InnoDB + DEFAULT CHARACTER SET = utf8mb4;