Skip to content
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] #107 - Rds비용 부담 문제로 인한 oracle -> mysql로 데이터 마이그레이션 작업 #108

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
.env
.env-prod
*.java~

### STS ###
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ dependencies {
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// runtimeOnly 'com.oracle.database.jdbc:ojdbc8:19.8.0.0'
runtimeOnly 'com.oracle.database.jdbc:ojdbc6:11.2.0.4'
//runtimeOnly 'com.oracle.database.jdbc:ojdbc6:11.2.0.4'
implementation 'mysql:mysql-connector-java:8.0.33'
annotationProcessor 'org.projectlombok:lombok'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/wooribound/domain/employment/Employment.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,9 @@
@Table(name = "employment")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "employment_seq_generator",
sequenceName = "employment_SEQ",
allocationSize = 1
)
public class Employment {
@Id
@GeneratedValue(
strategy= GenerationType.AUTO,
generator = "employment_seq_generator"
)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "emp_id")
private Long empId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Enterprise {
private Date deleteRequestedAt;

@Enumerated(EnumType.STRING)
@Column(name = "is_deleted", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'") // database default 설정 (jpql 사용에 대비)
@Column(name = "is_deleted", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'") // database default 설정 (jpql 사용에 대비)
private YNP isDeleted = YNP.N; // entity 필드 기본값 설정 (jpa 함수 사용을 통한 쿼리 생성 대비)

@OneToMany(mappedBy = "enterprise", fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@
@AllArgsConstructor
@RequiredArgsConstructor
@Table(name = "interest_job")
@SequenceGenerator(
name = "interest_job_seq_generator",
sequenceName = "interest_job_SEQ",
allocationSize = 1
)
public class InterestJob {
@Id
@GeneratedValue(
strategy = GenerationType.AUTO,
generator = "interest_job_seq_generator"
)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "interest_id")
private Long interestId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
public interface InterestJobRepository extends JpaRepository<InterestJob, Long> {
@Modifying
@Query(value = """
INSERT INTO interest_job (interest_id, job_id, user_id)
VALUES (
interest_job_SEQ.NEXTVAL,
(SELECT job_id FROM job WHERE CONVERT(job_name, 'UTF8') = CONVERT(:jobName, 'UTF8')),
:userId
)""", nativeQuery = true)
INSERT INTO interest_job (job_id, user_id)
VALUES (
(SELECT job_id FROM job WHERE job_name = :jobName),
:userId
)""", nativeQuery = true)
void saveInterestJob(@Param("userId") String userId, @Param("jobName") String jobName);

@Query("SELECT ij.job.jobName FROM InterestJob ij WHERE ij.wbUser.userId = :userId")
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/wooribound/domain/job/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@
@Table(name = "job")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "job_seq_generator",
sequenceName = "job_SEQ",
allocationSize = 1
)
public class Job {
@Id
@GeneratedValue(
strategy=GenerationType.AUTO,
generator = "job_seq_generator"
)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "job_id")
private Long jobId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
@Table(name = "job_posting")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "job_posting_seq_generator",
sequenceName = "job_posting_SEQ",
allocationSize = 1
)
public class JobPosting {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "post_id")
private Long postId;

Expand All @@ -44,7 +40,7 @@ public class JobPosting {
private Date endDate;

@Enumerated(EnumType.STRING)
@Column(name = "is_deleted", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'")
@Column(name = "is_deleted", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'")
private YN isDeleted = YN.N;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/wooribound/domain/knowhow/Knowhow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@
@Table(name = "knowhow")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "knowhow_seq_generator",
sequenceName = "knowhow_SEQ",
allocationSize = 1
)
public class Knowhow {

@Id
@Column(name = "knowhow_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long knowhowId;

@Column(name = "knowhow_job", length = 30, nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@
@Table(name = "knowhow_reported")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "knowhow_reported_seq_generator",
sequenceName = "knowhow_reported_SEQ",
allocationSize = 1
)
public class KnowhowReported {
@Id
@GeneratedValue(
strategy = GenerationType.AUTO,
generator = "knowhow_reported_seq_generator"
)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "reported_id")
private Long reportedId;

Expand Down
12 changes: 2 additions & 10 deletions src/main/java/com/wooribound/domain/notification/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@
@Table(name = "notification")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "notification_seq_generator",
sequenceName = "notification_SEQ",
allocationSize = 1
)
public class Notification {
@Id
// @GeneratedValue(
// strategy = GenerationType.AUTO,
// generator = "notification_seq_generator"
// )
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "noti_id")
private Long notiId;

Expand All @@ -42,7 +34,7 @@ public class Notification {
@Column(name = "notice", nullable = false, length = 200)
private String notice;

@Column(name = "is_confirmed", columnDefinition = "VARCHAR2(1) DEFAULT 'N'", nullable = false)
@Column(name = "is_confirmed", columnDefinition = "CHAR(1) DEFAULT 'N'", nullable = false)
@Enumerated(value = EnumType.STRING)
private YN isConfirmed;

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/wooribound/domain/resume/Resume.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
@Table(name = "resume")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "resume_seq_generator",
sequenceName = "resume_SEQ",
allocationSize = 1
)
public class Resume {
@Id
@Column(name = "resume_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long resumeId;

@OneToOne
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/wooribound/domain/userapply/UserApply.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
@Table(name = "user_apply")
@AllArgsConstructor
@Entity
@SequenceGenerator(
name = "user_apply_seq_generator",
sequenceName = "user_apply_SEQ",
allocationSize = 1
)
public class UserApply {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "apply_id")
private Long applyId;

Expand All @@ -51,7 +47,7 @@ public class UserApply {
private WbUser wbUser;

@Enumerated(value = EnumType.STRING)
@Column(name = "result", nullable = false, length = 40 , columnDefinition = "VARCHAR2(20) DEFAULT 'PENDING'")
@Column(name = "result", nullable = false, length = 40 , columnDefinition = "VARCHAR(20) DEFAULT 'PENDING'")
private ApplyResult result;

@Column(name = "apply_date", nullable = false)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/wooribound/domain/wbuser/WbUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public class WbUser {
@Enumerated(value = EnumType.STRING)
private Gender gender;

@Column(name = "exjob_chk", columnDefinition = "VARCHAR2(1) DEFAULT 'N'")
@Column(name = "exjob_chk", columnDefinition = "CHAR(1) DEFAULT 'N'")
@Enumerated(value = EnumType.STRING)
private YN exjobChk = YN.N;

@Column(name = "interest_chk", columnDefinition = "VARCHAR2(1) DEFAULT 'N'", nullable = false)
@Column(name = "interest_chk", columnDefinition = "CHAR(1) DEFAULT 'N'", nullable = false)
@Enumerated(value = EnumType.STRING)
private YN interestChk = YN.N;

Expand All @@ -70,11 +70,11 @@ public class WbUser {
@Column(name = "addr_province", length = 20)
private String addrProvince;

@Column(name = "job_point", nullable = false, columnDefinition = "NUMBER DEFAULT 0")
@Column(name = "job_point", nullable = false, columnDefinition = "INT DEFAULT 0")
private int jobPoint = 0;

@Enumerated(value = EnumType.STRING)
@Column(name = "job_interest", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'")
@Column(name = "job_interest", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'")
private YN jobInterest = YN.N;

@Column(name = "created_at", nullable = false) // NOT NULL 제약 조건
Expand All @@ -84,15 +84,15 @@ public class WbUser {
private Date updatedAt;

@Enumerated(value = EnumType.STRING)
@Column(name = "is_deleted", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'", length = 10) // NOT NULL 제약 조건
@Column(name = "is_deleted", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'", length = 10) // NOT NULL 제약 조건
private YN isDeleted = YN.N;

@Enumerated(value = EnumType.STRING)
@Column(name = "first_login", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'", length = 1)
@Column(name = "first_login", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'", length = 1)
private YN isInfoRegistered = YN.N;

@Enumerated(value = EnumType.STRING)
@Column(name = "data_sharing_consent", nullable = false, columnDefinition = "VARCHAR2(1) DEFAULT 'N'", length = 1)
@Column(name = "data_sharing_consent", nullable = false, columnDefinition = "CHAR(1) DEFAULT 'N'", length = 1)
private YN dataSharingConsent = YN.N;

@OneToOne(mappedBy = "wbUser", fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,9 @@
@AllArgsConstructor
@Entity
@Table(name = "work_history")
@SequenceGenerator(
name = "work_history_seq_generator",
sequenceName = "work_history_SEQ",
allocationSize = 1
)
public class WorkHistory {
@Id
@GeneratedValue(
strategy=GenerationType.AUTO,
generator = "work_history_seq_generator"
)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "exjob_id")
private Long exjobId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
public interface WorkHistoryRepository extends JpaRepository<WorkHistory, Long> {
@Modifying
@Query(value = """
INSERT INTO work_history (exjob_id, job_id, user_id)
VALUES (
work_history_SEQ.NEXTVAL,
(SELECT job_id FROM job WHERE CONVERT(job_name, 'UTF8') = CONVERT(:jobName, 'UTF8')),
:userId
)""", nativeQuery = true)
INSERT INTO work_history (job_id, user_id)
VALUES (
(SELECT job_id FROM job WHERE job_name = :jobName),
:userId
)""", nativeQuery = true)
void saveByJobName(@Param("userId") String userId, @Param("jobName") String jobName);

@Query("SELECT wh FROM WorkHistory wh WHERE wh.wbUser.userId = :userId")
Expand Down
59 changes: 59 additions & 0 deletions src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
server.port=8081

# .env ??
spring.config.import=optional:file:.env-prod[.properties]

targetIp = ${TARGET_IP}

# Mysql
spring.datasource.url=jdbc:mysql://${MYSQL_IP}:${MYSQL_PORT}/${MYSQL_DATABASE_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
spring.datasource.username=${MYSQL_USERNAME}
spring.datasource.password=${MYSQL_PASSWORD}

# JPA ????
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.highlight_sql=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.jdbc.time_zone= Asia/Seoul
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.defer-datasource-initialization=true
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

logging.level.org.hibernate.orm.jdbc.bind: trace

# data.sql ?? ??
spring.sql.init.mode=always

# naver OAuth2
spring.security.oauth2.client.registration.naver.client-id=${NAVER_CLIENT_ID}
spring.security.oauth2.client.registration.naver.client-secret=${NAVER_CLIENT_SECRET}
spring.security.oauth2.client.registration.naver.redirect-uri=${NAVER_CLIENT_REDIRECT_URL}
spring.security.oauth2.client.registration.naver.authorization-grant-type=authorization_code
spring.security.oauth2.client.registration.naver.scope=name
spring.security.oauth2.client.provider.naver.authorization-uri=https://nid.naver.com/oauth2.0/authorize
spring.security.oauth2.client.provider.naver.token-uri=https://nid.naver.com/oauth2.0/token
spring.security.oauth2.client.provider.naver.user-info-uri=https://openapi.naver.com/v1/nid/me
spring.security.oauth2.client.provider.naver.user-name-attribute=response

# jwt
jwt.secret=${JWT_SECRET_KEY}
jwt.expiration=86400

# redis
spring.data.redis.host=${REDIS_HOST}
spring.data.redis.port=${REDIS_PORT}
spring.data.redis.password=${REDIS_PASSWORD}
spring.data.redis.timeout=5000ms

# imgfile
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB

# S3
cloud.aws.credentials.accessKey=${AWS_ACCESS_KEY}
cloud.aws.credentials.secretKey=${AWS_SECRET_KEY}
cloud.aws.s3.bucketName=${AWS_BUCKET_NAME}
cloud.aws.region.static=${AWS_REGION}
cloud.aws.stack.auto-=false
Loading