Skip to content

Commit

Permalink
📦 [CHORE] InitDb 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ddongseop authored Jan 14, 2024
1 parent 2a1e352 commit d6781d2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/org/sopt/lequuServer/InitDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ static class InitService {

@Transactional
public void dbInit() {

if (!isDatabaseEmpty()) {
return;
}

Member member1 = Member.builder()
.socialPlatform(SocialPlatform.KAKAO)
.socialId("3251153440")
Expand Down Expand Up @@ -155,5 +160,11 @@ public void dbInit() {
.build();
em.persist(postedSticker);
}

private boolean isDatabaseEmpty() {
Long count = em.createQuery("SELECT COUNT(m) FROM Member m", Long.class)
.getSingleResult();
return count == 0;
}
}
}
}

0 comments on commit d6781d2

Please sign in to comment.