protected void runMigration(SqlMigration migration) {
        LOGGER.info("Running migration {}", migration);
        try (final Connection conn = getConnection(); final Transaction tran = new Transaction(conn)) {
            if (!isEmptyMigration(migration)) {
                runMigrationStatement(conn, migration);
            }
            updateMigrationsTable(conn, migration);
            tran.commit();
        } catch (Exception e) {
            throw shouldNotHappenException(new IllegalStateException("Error running database migration " + migration.getFileName(), e));
        }
    }
@Test
    void testMigrationIsNotDoneMoreThanOnce() {
        final JdbcDataSource dataSource = createH2DataSource("jdbc:h2:mem:/test;DB_CLOSE_DELAY=-1");
        final DatabaseCreator databaseCreator = Mockito.spy(new DatabaseCreator(dataSource, H2StorageProvider.class));

        assertThatCode(databaseCreator::runMigrations).doesNotThrowAnyException();

        insertExtraMigrationInDB(dataSource, databaseCreator);
        Mockito.reset(databaseCreator);

        assertThatCode(databaseCreator::runMigrations)
                .isInstanceOf(IllegalStateException.class)
                .hasMessage("A migration was applied multiple times (probably because it took too long and the process was killed). " +
                        "Please cleanup the migrations_table and remove duplicate entries.");

        verify(databaseCreator, never()).runMigration(any());
    }