Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

Is there any solution for DB entity dependency handling

$
0
0
Hi,

Some DB entities have dependencies. e.g a view / stored procedure depends on views / tables it uses. Is there a way to handle it with xml changelog?

In my scenario ViewB uses ViewA. To change ViewA steps required:
  1. ViewB needs to be dropped.
  2. ViewA needs to be changed
  3. ViewB needs to be recreated

I have the following changesets:

<changeSet id="Create ViewA" runOnChange="true" ...>
      <createView viewName="ViewA" replaceIfExists="true" .../></changeSet>

<changeSet id="Create ViewB" runOnChange="true" ...>
      <createView viewName="ViewB" remarks="Uses ViewA" .../></changeSet>

The only solution I've found to drop and recreate all the views all the time, but that's far from ideal.
  • dropView throws an error if the view does not exists so that needs to be in a separate changeSet with precondition
Some ideas:
  • dropView should have an option 'ifExists' avoiding error if the view does not exists
  • dropView could have an option to drop all dependent objects. (The dependency can be retrieved from the DB.)
  • Some way to call or ask another changeSet to be executed later. In that case if a dependent view (ViewA) has been changed. The changeset drops the depending view(s) (ViewB) and ask liquibase to execute the changesets recreating it. This feature could be used in many other cases. liquibase only needs to change the flag if a changeSet needs to be executed.
  • Similar: changeSet could have a 'dependsOn' option listing the changesets it depends on. If the depended changeset was executed, execute this also even if not changed
  • precondition similar to changeSetExecuted (or just a option)  to check if a changeSet was executed in the current execution.
Thanks,
    Gyula Bibernáth

Viewing all articles
Browse latest Browse all 2993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>