title: liquibase.exception.MigrationFailedException: Migration failed for change set - Error during database initialization for all integration tests
body: <p>I have a lot of integration tests and I have set up liquibase so that the database can be initialized. But each test class initializes a new initialization. In this case, duplicate data errors are unavoidable. I found a few recommendations to avoid this, but ran into a problem.</p>
  <ul>
  <li>changelog-1.xml</li>
  </ul>
  <pre class="lang-xml prettyprint-override"><code>&lt;databaseChangeLog
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns=&quot;http://www.liquibase.org/xml/ns/dbchangelog&quot;
    xsi:schemaLocation=&quot;http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd&quot;&gt;
  
    &lt;changeSet author=&quot;n&quot; context=&quot;test&quot; id=&quot;1&quot; runOnChange=&quot;false&quot;&gt;
      &lt;sqlFile encoding=&quot;utf8&quot; endDelimiter=&quot;\nGO&quot; path=&quot;classpath:dump.sql&quot; relativeToChangelogFile=&quot;false&quot;/&gt;
    &lt;/changeSet&gt;
  &lt;/databaseChangeLog&gt;
  </code></pre>
  <ul>
  <li>master</li>
  </ul>
  <pre class="lang-xml prettyprint-override"><code>&lt;databaseChangeLog
          xmlns=&quot;http://www.liquibase.org/xml/ns/dbchangelog&quot;
          xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
          xsi:schemaLocation=&quot;http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd&quot;&gt;
  
      &lt;include file=&quot;xml/changelog-1.xml&quot; relativeToChangelogFile=&quot;true&quot;/&gt;
  
  
  &lt;/databaseChangeLog&gt;
  
  </code></pre>
  <p>I have also written a configuration class .</p>
  <p>In the package :</p>
  <ul>
  <li>liquibase.ext</li>
  </ul>
  <pre class="lang-java prettyprint-override"><code>public class CleanUpDatabaseTestExecutionListener extends AbstractTestExecutionListener {
  
      @Autowired
      SpringLiquibase liquibase;
  
      @Override
      public int getOrder() {
          return Ordered.HIGHEST_PRECEDENCE;
      }
  
      @Override
      public void afterTestClass(TestContext testContext) throws Exception {
          testContext.getApplicationContext()
                  .getAutowireCapableBeanFactory()
                  .autowireBean(this);
          liquibase.afterPropertiesSet();
      }
  }
  </code></pre>
  <ul>
  <li>context</li>
  </ul>
  <pre class="lang-java prettyprint-override"><code>@Slf4j
  @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
  @TestExecutionListeners(listeners = {
          DependencyInjectionTestExecutionListener.class,
          TransactionalTestExecutionListener.class,
          CleanUpDatabaseTestExecutionListener.class,
  })
  public abstract class AbstractTestcontainers extends ContainerConfig {
  </code></pre>
  <blockquote>
  <h2>I get an error: liquibase.exception.MigrationFailedException:
  Migration failed for change set
  db/changelog/test/liquibase-initdb.xml::1::n:
  Reason: liquibase.exception.DatabaseException: ERROR: type &quot;calc_types&quot; already exists [Failed SQL: (0) --
  -- PostgreSQL database dump</h2>
  </blockquote>
  <p>spring.liquibase.drop-first=true - It doesn't work.</p>
  <p>Maybe who know how can i correct this ?</p>