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
Flyway integration issue - #5344 #5349
Changes from all commits
b6184af
71d3be7
eca407b
5f42f44
e714294
6b2a179
91f6574
15e7840
85fefec
c1f5282
94ca97e
e0deabf
d458c83
0c10897
1a4e84a
3b07490
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.harvard.iq.dataverse.flyway; | ||
|
||
import org.flywaydb.core.Flyway; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
import javax.ejb.Singleton; | ||
import javax.ejb.Startup; | ||
import javax.ejb.TransactionManagement; | ||
import javax.ejb.TransactionManagementType; | ||
import javax.sql.DataSource; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
@Startup | ||
@Singleton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While reading into Flyway in a Java EE context, I stumbled over the annotation The explanation sounds reasonable - should this be added here? |
||
@TransactionManagement(value = TransactionManagementType.BEAN) | ||
class StartupFlywayMigrator { | ||
|
||
@Resource(lookup = "jdbc/VDCNetDS") | ||
private DataSource dataSource; | ||
|
||
@PostConstruct | ||
void migrateDatabase() { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO a check on |
||
if (dataSource == null){ | ||
throw new NullPointerException("Failed to migrate, cannot connect to database"); | ||
} | ||
|
||
Flyway flyway = Flyway.configure() | ||
.dataSource(dataSource) | ||
.baselineOnMigrate(true) | ||
.load(); | ||
|
||
flyway.migrate(); | ||
} | ||
} |
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.
This may be nitpicking, but I don't fully get why it is necessary to change "upgrade scripts" and "scripts" to "SQLs". I don't see how it makes the text any better; and it's not even a proper use of the word.
?
(I can understand if you feel it is important to have the word "SQL" in there; rather than to just say "script" or "upgrade script". Still, it should probably be "SQL script" and/or "SQL upgrade script", etc. then.)