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: Flyway DDL 파일 추가 (#11) #24

Merged
merged 3 commits into from
Dec 14, 2023
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
4 changes: 1 addition & 3 deletions src/main/kotlin/kr/galaxyhub/sc/news/domain/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.Lob
import jakarta.persistence.ManyToOne

@Entity
Expand All @@ -35,11 +34,10 @@ class Content(
protected set

@Enumerated(EnumType.STRING)
@Column(name = "language", nullable = false)
@Column(name = "language", nullable = false, columnDefinition = "varchar")
var language: Language = language
protected set

@Lob
@Column(name = "content", nullable = false)
var content: String = content
protected set
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/kr/galaxyhub/sc/news/domain/News.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class News(
) : PrimaryKeyEntity() {

@Enumerated(EnumType.STRING)
@Column(name = "news_type", nullable = false)
@Column(name = "news_type", nullable = false, columnDefinition = "varchar")
var newsType: NewsType = newsType
protected set

@Column(name = "origin_id", nullable = false)
var originId: Long = originId
protected set

@Column(name = "originUrl", nullable = false)
@Column(name = "origin_url", nullable = false)
var originUrl: String = originUrl
protected set

Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
spring:
datasource:
url: jdbc:mysql://localhost:13306/sckorea
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
open-in-view: false
hibernate:
ddl-auto: validate
show-sql: true
flyway:
enabled: true
baseline-on-migrate: true
baseline-version: 1
logging:
level:
org:
hibernate:
orm:
jdbc:
bind: trace
26 changes: 26 additions & 0 deletions src/main/resources/db/migration/V1__init_news.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CREATE TABLE content
(
sequence BIGINT AUTO_INCREMENT NOT NULL,
news_id BINARY(16) NOT NULL,
language VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
title VARCHAR(255) NOT NULL,
excerpt VARCHAR(255) NULL,
CONSTRAINT pk_content PRIMARY KEY (sequence)
);

CREATE TABLE news
(
id BINARY(16) NOT NULL,
news_type VARCHAR(255) NOT NULL,
origin_id BIGINT NOT NULL,
origin_url VARCHAR(255) NOT NULL,
published_at DATETIME NOT NULL,
support_languages VARCHAR(255) NOT NULL,
title VARCHAR(255) NOT NULL,
excerpt VARCHAR(255) NULL,
CONSTRAINT pk_news PRIMARY KEY (id)
);

ALTER TABLE content
ADD CONSTRAINT FK_CONTENT_ON_NEWS FOREIGN KEY (news_id) REFERENCES news (id);