0
votes

I have two schemas: OWNER & USER in my Oracle database. Basically, all tables are created in OWNER, and after it synonyms are created using USER account.

<execution>
    <id>apply.owner</id>
    <phase>process-resources</phase>
    <configuration>
        <url>${database.url}</url>
        <username>${database.owner.user}</username>
        <password>${database.owner.password}</password>
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <changeLogFile>${changelog.owner.file}</changeLogFile>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
    </configuration>
    <goals>
        <goal>update</goal>
    </goals>
</execution>

<execution>
    <id>apply.user</id>
    <phase>process-resources</phase>
    <configuration>
        <url>${database.url}</url>
        <username>${database.user.user}</username>
        <password>${database.user.password}</password
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <changeLogFile>${changelog.user.file</changeLogFile>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
    </configuration>
    <goals>
        <goal>update</goal>
    </goals>
</execution>

DATABASECHANGELOG(LOCK) tables were created for OWNER account, synonyms for USER account were added, and I am able to see them in SQL developer. But when I'm running initial migration for USER schema I got:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.0.8:rollback (apply.user) on project liquitest: Error setting up or running Liquibase: liq
uibase.exception.DatabaseException: Error executing SQL CREATE TABLE DATABASECHANGELOGLOCK (ID NUMBER(10) NOT NULL, LOCKED NUMBER(1) NOT NULL, LOCKGRANTED TIMES
TAMP, LOCKEDBY VARCHAR2(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID)): ORA-01031: insufficient privileges -> [Help 1]

Why it tries to create this table when I can select from DATABASECHANGELOGLOCK table using USER account? Thanks!

1

1 Answers

2
votes

Liquibase checks the database metadata for the existence of the databasechangelog table, but it does not have functionality to look at synonyms, unfortunately.

If you need to have USER.DATABASECHANGELOG as a synonym, you would need to create a subclass of liquibase.snapshot.jvm.TableSnapshotGenerator that can handle synonyms or hard-codes a response for the DATABASECHANGELOG table.