You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Liquibase生成AWS Redshift变更日志遇information_schema.sequences不存在错误

解决Liquibase生成AWS Redshift变更日志时的"relation 'information_schema.sequences'不存在"错误

问题概述

使用Liquibase 4.20.0跟踪现有AWS Redshift数据库,执行generate-changelog命令时触发错误,核心报错为relation "information_schema.sequences" does not exist,导致事务中止,根源是Liquibase未正确适配Redshift的元数据存储结构。

错误执行日志

❯ liquibase generate-changelog --changeLogFile="gen.sql"
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 20:27:03 (version 4.20.0 #7837 built at 2023-03-07 16:25+0000)
Liquibase Version: 4.20.0
Liquibase Open Source 4.20.0 by Liquibase

Unexpected error running Liquibase: ERROR: current transaction is aborted, commands ignored until end of transaction block
  - Caused by: ERROR: relation "information_schema.sequences" does not exist

Liquibase配置文件(liquibase.properties)

changeLogFile:report.changelog-root.xml
url:  jdbc:redshift://localhost:1234/project_name
username:  <<UserGoesHere>>
password:  <<Passy-McPasswordFace>> 
driver: com.amazon.redshift.jdbc42.Driver
classpath:  lib/liquibase-redshift-4.20.0.jar

解决方案

Redshift不支持information_schema.sequences视图(序列元数据存储在pg_catalog.pg_sequences中),需通过以下步骤确保Liquibase使用Redshift专属适配逻辑:

  • 显式指定Redshift数据库类:在liquibase.properties中添加配置,强制Liquibase加载Redshift适配,避免通用JDBC适配查询错误的元数据表:

    databaseClass: liquibase.database.core.RedshiftDatabase
    
  • 修正JDBC URL配置:若使用非默认schema,在URL中添加currentSchema参数,确保Liquibase访问正确的schema:

    url: jdbc:redshift://localhost:1234/project_name?currentSchema=你的schema名称
    
  • 验证扩展加载路径:检查liquibase-redshift-4.20.0.jar是否被正确加载,可改为绝对路径配置classpath:

    classpath: "C:/Program Files/liquibase/lib/liquibase-redshift-4.20.0.jar"
    
  • 升级Liquibase版本:若上述方法无效,升级到4.24.0及以上版本,新版本修复了Redshift元数据查询的适配问题。

内容的提问来源于stack exchange,提问作者AdamSane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 00:05:30