-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only change the column of the table exists
The CI build fails on the alter table SPRING_SESSION_ATTRIBUTES as it does not exists prior to initialising spring session
- Loading branch information
Showing
4 changed files
with
29 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
23 changes: 23 additions & 0 deletions
23
server/src/main/java/db/mysql/migration/V31_0__session_attributes_medium_blob.java
This file contains 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,23 @@ | ||
package db.mysql.migration; | ||
|
||
import org.flywaydb.core.api.migration.BaseJavaMigration; | ||
import org.flywaydb.core.api.migration.Context; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.jdbc.datasource.SingleConnectionDataSource; | ||
|
||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
//Only change the column of the table exists, otherwise the CI build fails | ||
public class V31_0__session_attributes_medium_blob extends BaseJavaMigration { | ||
|
||
public void migrate(Context context) { | ||
JdbcTemplate jdbcTemplate = | ||
new JdbcTemplate(new SingleConnectionDataSource(context.getConnection(), true)); | ||
jdbcTemplate.query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES " + | ||
"WHERE TABLE_SCHEMA = 'invite' " + | ||
"AND TABLE_NAME = 'SPRING_SESSION_ATTRIBUTES'", rs -> { | ||
jdbcTemplate.update("ALTER TABLE SPRING_SESSION_ATTRIBUTES " + | ||
"CHANGE COLUMN ATTRIBUTE_BYTES ATTRIBUTE_BYTES MEDIUMBLOB"); | ||
}); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
server/src/main/resources/db/mysql/migration/V31_0__session_attributes_medium_blob.sql
This file was deleted.
Oops, something went wrong.