Skip to content

Instantly share code, notes, and snippets.

@AdamBien
Created June 7, 2018 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamBien/bfa3a444b6af3316e772f8eaf133f1cb to your computer and use it in GitHub Desktop.
Save AdamBien/bfa3a444b6af3316e772f8eaf133f1cb to your computer and use it in GitHub Desktop.
52ndAirhacksQ&A.md
@rieckpil
Copy link

rieckpil commented Jun 30, 2018

Hi Adam,

I have three questions for the upcoming airhacks show:

  1. How do migrate your database schema with Flyway? Do you use the Java/Maven or CLI approach?

What do you think about the following solution (JavaEE 8, OpenLiberty 18.0.0.2, Flyway 5.0.7)?

@Startup
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Singleton
public class FlywayMigration {

    private final Logger log = Logger.getLogger(this.getClass().getName());

    @Resource(lookup = "jdbc/sample")
    DataSource dataSource;

    @PostConstruct
    private void onStartup() {

        if (dataSource == null) {
            log.severe("no datasource found to execute the db migrations!");
            throw new RuntimeException(
                    "no datasource found to execute the db migrations!");
        }

        Flyway flyway = new Flyway();
        flyway.setDataSource(dataSource);
        for (MigrationInfo i : flyway.info().all()) {
            log.info("migrate task: " + i.getVersion() + " : "
                    + i.getDescription() + " from file: " + i.getScript());
        }
        flyway.migrate();

    }
}

And what's your Flyway strategy in enterprise projects for the SQL scripts? Do you create a single SQL script for every change during the Sprint or do you collect all changes during one sprint/cycle and squash them into one single SQL script, so that /db/migration won't grow that much?

  1. What are the three most important books about Programming/Software Design/Java every developer should read in your opinion?

  2. If you could give your 20-year-old self three lessons for your Developer career, what would it be?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment