Skip to content

Commit

Permalink
Flyway migration refactoring to avoid naming errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaceccanti committed Nov 5, 2021
1 parent 3f5e741 commit 3efc9f9
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 11 deletions.
3 changes: 3 additions & 0 deletions iam-login-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ server:
path: /error

port: ${IAM_PORT:8080}

tomcat:
additional-tld-skip-patterns:
- "*.jar"
accesslog:
enabled: ${IAM_TOMCAT_ACCESS_LOG_ENABLED:false}
directory: ${IAM_TOMCAT_ACCESS_LOG_DIRECTORY:/tmp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import org.springframework.jdbc.core.JdbcTemplate;

import db.migration.tasks.CreateGroupManagerAuthorities;
import it.infn.mw.iam.persistence.migrations.BaseFlywayJavaMigrationAdapter;
import it.infn.mw.iam.persistence.migrations.CreateGroupManagerAuthorities;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;

import db.migration.tasks.CreateGroupManagerAuthorities;
import it.infn.mw.iam.persistence.migrations.BaseFlywayJavaMigrationAdapter;
import it.infn.mw.iam.persistence.migrations.CreateGroupManagerAuthorities;

public class V23___CreateGroupManagerAuthorities extends BaseFlywayJavaMigrationAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.infn.mw.iam.persistence.migrations;
package db.migration.tasks;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;

public class CreateGroupManagerAuthorities extends BaseFlywayJavaMigrationAdapter {
import it.infn.mw.iam.persistence.migrations.SpringJdbcFlywayMigration;

public class CreateGroupManagerAuthorities implements SpringJdbcFlywayMigration {

public static final Logger LOG = LoggerFactory.getLogger(CreateGroupManagerAuthorities.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;

import it.infn.mw.iam.persistence.migrations.BaseFlywayJavaMigrationAdapter;
import it.infn.mw.iam.persistence.migrations.SpringJdbcFlywayMigration;

public class RemoveOrphanTokens extends BaseFlywayJavaMigrationAdapter {
public class RemoveOrphanTokens implements SpringJdbcFlywayMigration {

public static final Logger LOG = LoggerFactory.getLogger(RemoveOrphanTokens.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import org.springframework.jdbc.core.JdbcTemplate;

import db.migration.tasks.CreateGroupManagerAuthorities;
import it.infn.mw.iam.persistence.migrations.BaseFlywayJavaMigrationAdapter;
import it.infn.mw.iam.persistence.migrations.CreateGroupManagerAuthorities;

public class V100000_1___CreateGroupManagerAuthorities extends BaseFlywayJavaMigrationAdapter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;

public abstract class BaseFlywayJavaMigrationAdapter extends BaseJavaMigration {
public abstract class BaseFlywayJavaMigrationAdapter extends BaseJavaMigration
implements SpringJdbcFlywayMigration {

protected JdbcTemplate templateFromContext(Context context) {
return new JdbcTemplate(new SingleConnectionDataSource(context.getConnection(), true));
Expand All @@ -31,6 +32,4 @@ public void migrate(Context context) throws Exception {
migrate(templateFromContext(context));
}

public abstract void migrate(JdbcTemplate jdbcTemplate) throws Exception;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package it.infn.mw.iam.persistence.migrations;

import org.springframework.jdbc.core.JdbcTemplate;

@FunctionalInterface
public interface SpringJdbcFlywayMigration {

void migrate(JdbcTemplate jdbcTemplate) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ALTER TABLE iam_aup MODIFY text LONGTEXT NULL;
ALTER TABLE iam_aup ALTER COLUMN text LONGTEXT NULL;
ALTER TABLE iam_aup ADD COLUMN url VARCHAR(256);

0 comments on commit 3efc9f9

Please sign in to comment.