@@ -0,0 +1,1797 @@
+package db.migration;%0A%0Aimport org.flywaydb.core.api.migration.spring.SpringJdbcMigration;%0Aimport org.springframework.jdbc.core.JdbcTemplate;%0A%0A/**%0A * Created by emma on 06/04/2016.%0A *%0A * @author emma *         %3Cp%3E Copy OR and DESCRIPTION values to BETA_NUM, BETA_UNIT and BETA_DIRECTION in ASSOCIATION%0A *         table%0A */%0Apublic class V2_1_2_014__Migrate_or_to_beta_for_description_with_brackets implements SpringJdbcMigration %7B%0A%0A    // Query to find beta associations with a description with a bracket.%0A    private static final String SELECT_ASSOCIATIONS =%0A            %22SELECT ID, OR_PER_COPY_NUM, DESCRIPTION FROM ASSOCIATION %5Cn%22 +%0A                    %22WHERE OR_TYPE = 0 %5Cn%22 +%0A                    %22AND DESCRIPTION IS NOT NULL  %5Cn%22 +%0A                    %22AND OR_PER_COPY_NUM IS NOT NULL %5Cn%22 +%0A                    %22AND DESCRIPTION LIKE '(unit%25'%5Cn%22;%0A%0A    private static final String UPDATE_ASSOCIATION =%0A            %22UPDATE ASSOCIATION SET BETA_NUM = ?, BETA_UNIT = ? , BETA_DIRECTION= ? , OR_PER_COPY_NUM=?, DESCRIPTION=? WHERE ID = ?%22;%0A%0A    @Override%0A    public void migrate(JdbcTemplate jdbcTemplate) throws Exception %7B%0A%0A        jdbcTemplate.query(SELECT_ASSOCIATIONS, (resultSet, i) -%3E %7B%0A            Long id = resultSet.getLong(1);%0A            float betaNum = resultSet.getFloat(2);%0A            String description = resultSet.getString(3).trim();%0A%0A            // Split description%0A            int lastIndexOfSpace = description.lastIndexOf(%22 %22);%0A            String unit = description.substring(1, lastIndexOfSpace);%0A            String direction = description.substring(lastIndexOfSpace, description.length() - 1);%0A%0A            // Run update%0A            jdbcTemplate.update(UPDATE_ASSOCIATION, betaNum, unit.trim(), direction.trim(), null, null, id);%0A            return null;%0A        %7D);%0A    %7D%0A%7D

Migrate betas with brackets in description