0

I want to use a custom sql bracket in Liquibase that looks like this:

<sql>
  CREATE TRIGGER insert_${param1}_trigger
    BEFORE INSERT ON ${param1}
      FOR EACH ROW BEGIN
        SET NEW.created_at = NOW();
        SET NEW.updated_at = NOW();
      END
</sql>

I would like to call this function in several different changesets and specify param1. I know the inverse functionality is possible because you can specify properties with the <property name="name" value="value"> tag and input the ${name} variable to get the value inserted into the file. However, I am looking to supply the parameter and have the sql above be included in the changeset. Any more general XML or SQL approaches are welcome as well.

4

2 回答 2

1

我认为您正在寻找的是自定义更改更改扩展

两者都允许您指定一个可以接受参数并创建应该运行的 SQL 的 java 类。

于 2013-10-29T18:26:36.740 回答
0

您是否检查了如何参数化您的更改日志

根据文档:

按以下顺序查找参数值:

  • 作为参数传递给您的 Liquibase 运行器;

  • 作为 JVM 系统属性;

  • 在 DatabaseChangeLog 文件本身的参数块 (Tag) 中。

于 2014-04-01T21:16:17.207 回答