diff --git a/src/main/kotlin/kr/galaxyhub/sc/news/domain/Content.kt b/src/main/kotlin/kr/galaxyhub/sc/news/domain/Content.kt index 3827ed6..1fa2507 100644 --- a/src/main/kotlin/kr/galaxyhub/sc/news/domain/Content.kt +++ b/src/main/kotlin/kr/galaxyhub/sc/news/domain/Content.kt @@ -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 @@ -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 diff --git a/src/main/kotlin/kr/galaxyhub/sc/news/domain/News.kt b/src/main/kotlin/kr/galaxyhub/sc/news/domain/News.kt index 6cb0e0d..9b13eb2 100644 --- a/src/main/kotlin/kr/galaxyhub/sc/news/domain/News.kt +++ b/src/main/kotlin/kr/galaxyhub/sc/news/domain/News.kt @@ -24,7 +24,7 @@ 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 @@ -32,7 +32,7 @@ class News( var originId: Long = originId protected set - @Column(name = "originUrl", nullable = false) + @Column(name = "origin_url", nullable = false) var originUrl: String = originUrl protected set diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index d1acd8a..8682bd4 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -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 diff --git a/src/main/resources/db/migration/V1__init_news.sql b/src/main/resources/db/migration/V1__init_news.sql new file mode 100644 index 0000000..6fa88f5 --- /dev/null +++ b/src/main/resources/db/migration/V1__init_news.sql @@ -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);