Migliorie in BaseMigration
This commit is contained in:
@@ -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" +
|
String sql = Query.format("SELECT 1 FROM sys.columns\n" +
|
||||||
" WHERE Name = N{}\n" +
|
" WHERE Name = N{}\n" +
|
||||||
" AND Object_ID = Object_ID(N{})", columnName, "dbo." + tableName);
|
" 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;
|
return val != null && val == 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Migration_20230411163906 extends BaseMigration implements Migration
|
|||||||
|
|
||||||
MimeTypesHandler mimeTypesHandler = getContextBean(MimeTypesHandler.class);
|
MimeTypesHandler mimeTypesHandler = getContextBean(MimeTypesHandler.class);
|
||||||
|
|
||||||
if (!existsColumn(advancedDataSource.getConnection(), "stb_files_attached", "mime_type"))
|
if (!existsColumn("stb_files_attached", "mime_type"))
|
||||||
executeStatement(
|
executeStatement(
|
||||||
"ALTER TABLE stb_files_attached\n" +
|
"ALTER TABLE stb_files_attached\n" +
|
||||||
" ADD mime_type VARCHAR(MAX)");
|
" ADD mime_type VARCHAR(MAX)");
|
||||||
|
|||||||
Reference in New Issue
Block a user