簡體   English   中英

獲取 Liquibase SQL 服務器錯誤“找不到 object... 因為它不存在或您沒有權限”

[英]Getting Liquibase SQL Server error 'Cannot find the object ... because it doesn't exist or you do not have permissions'

我有一個演示 SQL 服務器數據庫在 Docker 容器中運行,我正在它上面測試 Liquibase。 我創建了一個變更日志文件並放入了兩個變更集,它們將從特定表中刪除兩列。

這是我的 Liquibase 變更日志文件:

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:pro="http://www.liquibase.org/xml/ns/pro"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd
    http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd ">

    <changeSet id="1" author="mdailey">
        <dropColumn tableName="Sales.Invoices" columnName="RunPosition">
        </dropColumn>
    </changeSet>
    <changeSet id="2" author="mdailey">
        <dropColumn tableName="Sales.Invoices" columnName="DeliveryRun">
        </dropColumn>
    </changeSet>
</databaseChangeLog>

當我運行liquibase update時,我不斷收到以下錯誤:

Unexpected error running Liquibase: Cannot find the object "Sales.Invoices" because it does not exist or you do not have permissions. [Failed SQL: (4902) ALTER TABLE [Sales.Invoices] DROP COLUMN RunPosition]

我正在使用 Microsoft 提供的示例數據庫 WideWorldImporters 架構是 Sales,因此表名是正確的。 我有一個名為 sqladmin 的用戶和登錄名,登錄信息位於 Liquibase 屬性文件中。 這是屬性文件:

# Enter the path for your changelog file.
changeLogFile=changelog/db.changelog-root.xml

# Enter the Target database 'url' information #
liquibase.command.url=jdbc:sqlserver://localhost:1401;database=WideWorldImporters

# Enter the username for your Target database.
liquibase.command.username: sqladmin    

# Enter the password for your Target database.
liquibase.command.password: <StrongPassword>

我將 sqladmin 添加到 db_datawriter 角色,因此它具有足夠的權限。 當我在 SQL 服務器中以“sqladmin”身份運行 T-SQL 語句以從同一表中刪除同一列時,它會成功執行。 我認為問題出在 Liquibase 但我不知道是什么。

感謝@SMor 的建議,我找到了解決方案。

在變更集中,您不在表前面添加模式名稱,而是需要將其作為單獨的屬性添加。

<changeSet id="1" author="mdailey">
        <dropColumn schemaName="Sales" tableName="Invoices" columnName="RunPosition">
        </dropColumn>
    </changeSet>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM