private void addEditorSpecificFields ( Connection connection , String tablePrefix , Table table ) throws SQLException { LOG . info ( "Adding any missing columns for {}" , tablePrefix + table . name ) ; Statement statement = connection . createStatement ( ) ; for ( Field field : table . editorFields ( ) ) { // The following statement requires PostgreSQL 9.6+. String addColumnSql = String . format ( "ALTER TABLE %s ADD COLUMN IF NOT EXISTS %s %s" , tablePrefix + table . name , field . name , field . getSqlTypeName ( ) ) ; LOG . info ( addColumnSql ) ; statement . execute ( addColumnSql ) ; } }
Add columns for any required optional or editor fields that don t already exist as columns on the table . This method contains a SQL statement that requires PostgreSQL 9 . 6 + .