运行使用Liquibase的自定义”drop-first”脚本。

huangapple 未分类评论44阅读模式
英文:

Running a custom drop-first script with Liquibase

问题

我们希望在我们的一个自动化测试环境中删除模式的所有内容,并从Liquibase更改日志中重新创建模式对象。由于我们在使用带有引用分区的Oracle时遇到了问题当存在引用分区表时,Liquibase dropAll失败,但不管怎样,我们将无法依赖于Liquibase dropAll,因为我们将使用其他特定于Oracle的对象。

我们尝试使用像这样的更改集(首个更改集中):

<changeSet author="foo" id="drop-schema" context="drop-first" runAlways="true">
  <validCheckSum>ANY</validCheckSum>
  <sqlFile path="classpath:/db/drop-schema.sql" splitStatements="true" stripComments="true" endDelimiter="/"/>
</changeSet>

... 并配合一个脚本,该脚本还会清空DATABASECHANGELOG表,但是这只能在每隔一次才能正常工作,因为执行实际上是更改集的一部分,不是在迁移之前而是在迁移期间运行。

我们不想采取编写Liquibase扩展的解决方案,如在postgresql中删除所有函数 - Liquibase中建议的那样。

我们如何能够在我们的某个环境中在Spring Boot启动时作为一部分运行我们的脚本,以在Liquibase迁移之前运行?我们正在考虑转向Flyway,它内置了对回调的支持,其中beforeMigrate看起来就是我们所需的...

英文:

We want to drop all content of a schema and recreate the schema objects from a Liquibase change log in one of our automated test environments. Since we are using Oracle with partition-by-reference we run into Liquibase dropAll fails when there are reference partitioned tables but regardless of that we will not be able to rely on Liquibase dropAll anyway because we will be using other Oracle-specific objects.

We have tried using a change set like this (first among the change sets):

&lt;changeSet author=&quot;foo&quot; id=&quot;drop-schema&quot; context=&quot;drop-first&quot; runAlways=&quot;true&quot;&gt;
  &lt;validCheckSum&gt;ANY&lt;/validCheckSum&gt;
  &lt;sqlFile path=&quot;classpath:/db/drop-schema.sql&quot; splitStatements=&quot;true&quot; stripComments=&quot;true&quot; endDelimiter=&quot;/&quot;/&gt;
&lt;/changeSet&gt;

... with a script that also empties the DATABASECHANGELOG table, but that only works every second time as the execution is actually part of the change set and not run before migration but during.

We do not want to resort to the solution of writing a Liquibase extension as suggested in Liquibase drop all functions - postgresql.

How can we have our script run before Liquibase migration in one of our environments as part of the spring boot startup? We are glancing towards Flyway instead which has built-in support for Callbacks where beforeMigrate looks like what we need...

huangapple
  • 本文由 发表于 2020年4月6日 17:06:03
  • 转载请务必保留本文链接:https://java.coder-hub.com/61056307.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定