Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

SQL Server Error 1785: Migration V2.9.0.20210423125133__assets_tags.sql fails with cascade delete conflict

未关闭
#2,467 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
sql
领域
database

调研方向

从 db/migration/sqlserver/V2.9.0.20210423125133__assets_tags.sql 开始,检查 webapi.tag_groups 上的两个外键。在全新的 SQL Server 数据库上运行 Flyway migration 以重现 Error 1785,然后验证 migration 是否能够成功完成,且不会引入无效的级联路径。

由索引模型根据 Issue 内容生成。

描述

Description

The Flyway migration V2.9.0.20210423125133__assets_tags.sql fails on SQL Server with Error 1785 due to multiple cascade delete paths on the tag_groups table.

Environment

  • WebAPI Version: 2.8.1
  • Database: Microsoft SQL Server 12.0 (Azure SQL Database)
  • Database Driver: com.microsoft.sqlserver.jdbc.SQLServerDriver (mssql-jdbc-10.2.1)
  • Flyway Version: 4.2.0

Error Message

SQL State  : S0000
Error Code : 1785
Message    : Introducing FOREIGN KEY constraint 'tag_groups_tag_fk' on table 'tag_groups' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Location   : db/migration/sqlserver/V2.9.0.20210423125133__assets_tags.sql

Root Cause

The migration creates the tag_groups table with two foreign keys, both with ON DELETE CASCADE, both referencing the same parent table (tags):

CREATE TABLE webapi.tag_groups
(
    tag_id   INT NOT NULL,
    group_id INT NOT NULL,
    CONSTRAINT tag_groups_group_fk FOREIGN KEY (group_id) REFERENCES webapi.tags (id) ON DELETE CASCADE,
    CONSTRAINT tag_groups_tag_fk FOREIGN KEY (tag_id) REFERENCES webapi.tags (id) ON DELETE CASCADE
);

Steps to Reproduce

  1. Set up fresh SQL Server database
  2. Configure WebAPI 2.8.1 to connect to SQL Server
  3. Enable Flyway migrations
  4. Start application
  5. Migration fails with Error 1785

Logs

ohdsi-webapi-debug-logs.txt

主要语言
Java
星标
153
派生
187
平均合并
1 天 1 小时
30 天内合并 PR
15

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OHDSI/WebAPI 的其他 Issue

查看 OHDSI/WebAPI 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。