如果未明确指定,liquibase select 模式如何实现?

How does liquibase select a schema if it is not explicitly specified?

我想为我的变更集使用 columnExists 前提条件, 但是指定一个确切的模式是不可能的,因为我们要 运行 多个环境中的东西,并且模式名称可能不同。

问题是,liquibase 选择的模式是否等同于

select sys_context('USERENV', 'CURRENT_SCHEMA') from dual;

如果重要的话,我们在这里谈论的是 Oracle。

在 Oracle 中,用户和模式之间存在一对一的关系。

您用于登录 Oracle 的用户帐户是默认架构,除非您在会话中主动更改了它。

我本来打算回答 "just leave out the schema",直到我看到 Liquibase 需要 schemaName 作为 columnExists 前提条件(我认为这有点愚蠢)

所以你不能真正使用 columnExists,你需要一个 <sqlCheck> 来代替:

<preConditions onFail="HALT">
  <sqlCheck expectedResult="1">
    select count(*) 
    from user_tab_columns 
    where column_name = 'SOME_COLUMN' 
      and table_name = 'SOME_TABLE'
  </sqlCheck>
</preConditions>

user_tab_columns 包含当前用户 拥有 (即创建)的表的列。