-
Notifications
You must be signed in to change notification settings - Fork 8
fix: flyway 전용 DataSource를 사용하도록 수정 #613
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
Merged
sukangpunch
merged 4 commits into
solid-connection:develop
from
sukangpunch:fix/612-flyway-datasource-config
Jan 20, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/com/example/solidconnection/common/config/datasource/DataSourceConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.example.solidconnection.common.config.datasource; | ||
|
|
||
| import com.example.solidconnection.common.listener.QueryMetricsListener; | ||
| import com.zaxxer.hikari.HikariDataSource; | ||
| import javax.sql.DataSource; | ||
| import lombok.RequiredArgsConstructor; | ||
| import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.boot.autoconfigure.flyway.FlywayDataSource; | ||
| import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Configuration | ||
| public class DataSourceConfig { | ||
|
|
||
| private final QueryMetricsListener queryMetricsListener; | ||
|
|
||
| @Bean | ||
| @Primary | ||
| public DataSource proxyDataSource(DataSourceProperties props) { | ||
| DataSource dataSource = props.initializeDataSourceBuilder().build(); | ||
|
|
||
| return ProxyDataSourceBuilder | ||
| .create(dataSource) | ||
| .listener(queryMetricsListener) | ||
| .name("main") | ||
| .build(); | ||
| } | ||
|
|
||
| // Flyway 전용 DataSource (Proxy 미적용) | ||
| @Bean | ||
| @FlywayDataSource | ||
| public DataSource flywayDataSource( | ||
| @Value("${spring.datasource.url}") String url, | ||
| @Value("${spring.flyway.user:${spring.datasource.username}}") String username, | ||
| @Value("${spring.flyway.password:${spring.datasource.password}}") String password | ||
| ) { | ||
| HikariDataSource dataSource = new HikariDataSource(); | ||
| dataSource.setJdbcUrl(url); | ||
| dataSource.setUsername(username); | ||
| dataSource.setPassword(password); | ||
| dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); | ||
| dataSource.setPoolName("FlywayPool"); | ||
|
|
||
| dataSource.setMinimumIdle(0); | ||
| dataSource.setMaximumPoolSize(2); | ||
| dataSource.setConnectionTimeout(10000); | ||
| dataSource.setIdleTimeout(60000); // 1분으로 단축 | ||
| dataSource.setMaxLifetime(300000); // 최대 5분 | ||
|
||
|
|
||
| return dataSource; | ||
| } | ||
| } | ||
29 changes: 0 additions & 29 deletions
29
...main/java/com/example/solidconnection/common/config/datasource/DataSourceProxyConfig.java
This file was deleted.
Oops, something went wrong.
Submodule secret
updated
from 1f9396 to 29524e
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 2578
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 154
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 115
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 713
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 3007
🏁 Script executed:
Repository: solid-connection/solid-connect-server
Length of output: 6233
🌐 Web query:
Spring Boot Flyway datasource properties spring.flyway.url spring.flyway.driver-class-name💡 Result:
spring.flyway.url — if set, Flyway will create and use its own DataSource for migrations (instead of the autowired spring.datasource). You usually set spring.flyway.url, spring.flyway.user and spring.flyway.password when you want Flyway to connect with different credentials or a different DB. [1][2]
spring.flyway.driver-class-name — optional; fully qualified JDBC driver class name. Spring Boot will auto-detect the driver from the JDBC URL, but set this property to remove ambiguity (multiple drivers on the classpath) or if auto-detection fails. [2]
Example (application.properties):
spring.datasource.url=jdbc:postgresql://localhost:5432/appdb
spring.datasource.username=app
spring.datasource.password=appPass
Flyway uses its own connection (can be same or different)
spring.flyway.url=jdbc:postgresql://localhost:5432/migrationsdb
spring.flyway.user=flyway
spring.flyway.password=flywayPass
spring.flyway.driver-class-name=org.postgresql.Driver
References:
[1] Spring Boot reference — Flyway support (explains that setting spring.flyway.url/user causes Flyway to use its own DataSource).
[2] Spring Boot application-properties appendix — spring.flyway.driver-class-name (auto-detected by default).
🌐 Web query:
Spring Boot FlywayProperties standard configuration properties💡 Result:
See the Spring Boot Flyway configuration reference and the FlywayProperties API for the canonical list of supported spring.flyway.* properties. Key entry points:
If you want, I can enumerate the common properties (spring.flyway.enabled, locations, baselineOnMigrate, baselineVersion, validateOnMigrate, outOfOrder, schemas, table, encoding, connectRetries, placeholders, sqlMigrationPrefix/suffix, skipDefaultCallbacks, skipDefaultResolvers, etc.) with exact names and brief meanings drawn from the API/docs — shall I list them in one response?
Flyway 전용 DataSource가 표준 설정 프로퍼티를 무시합니다
현재 구현은 두 가지 설정 문제를 가지고 있습니다:
spring.flyway.url 무시
spring.flyway.user와spring.flyway.password는 오버라이드를 지원하지만, URL은 항상spring.datasource.url만 사용됩니다.spring.flyway.url을 설정하면 Flyway가 자체 DataSource를 사용해야 합니다.드라이버 클래스 하드코딩
com.mysql.cj.jdbc.Driver로 고정되어 있어 PostgreSQL, Oracle 등 다른 데이터베이스 환경에서는 즉시 실패합니다.spring.flyway.driver-class-name프로퍼티로 명시할 수도 있습니다.다음과 같이 수정하여 표준 설정 오버라이드를 활성화해 주세요:
🛠️ 제안 변경
🤖 Prompt for AI Agents