Migliorie in BaseMigration

This commit is contained in:
2024-03-13 17:18:05 +01:00
parent 66612aae14
commit d8df7edaa3
2 changed files with 3 additions and 3 deletions

View File

@@ -117,12 +117,12 @@ public abstract class BaseMigration implements MigrationModelInterface {
}
protected boolean existsColumn(Connection connection, String tableName, String columnName) throws SQLException {
protected boolean existsColumn(String tableName, String columnName) throws SQLException, IOException {
String sql = Query.format("SELECT 1 FROM sys.columns\n" +
" WHERE Name = N{}\n" +
" AND Object_ID = Object_ID(N{})", columnName, "dbo." + tableName);
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(connection, sql);
Integer val = UtilityDB.<Integer>executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
return val != null && val == 1;
}

View File

@@ -20,7 +20,7 @@ public class Migration_20230411163906 extends BaseMigration implements Migration
MimeTypesHandler mimeTypesHandler = getContextBean(MimeTypesHandler.class);
if (!existsColumn(advancedDataSource.getConnection(), "stb_files_attached", "mime_type"))
if (!existsColumn("stb_files_attached", "mime_type"))
executeStatement(
"ALTER TABLE stb_files_attached\n" +
" ADD mime_type VARCHAR(MAX)");