Skip to content

Commit

Permalink
fix(mysql): mysql db重命名处理外键 #8512
Browse files Browse the repository at this point in the history
  • Loading branch information
xfwduke committed Dec 11, 2024
1 parent bf56263 commit 1803bbf
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ func transDBTable(conn *sqlx.Conn, from, to, tableName string) ([]string, error)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

// 这里的表是 backup others 新建出来的
_, err := conn.ExecContext(
ctx,
`SET FOREIGN_KEY_CHECKS=0`,
)
if err != nil {
return nil, err
}

// 这里的表是 backup others 新建出来的
_, err = conn.ExecContext(
ctx,
fmt.Sprintf("DROP TABLE IF EXISTS `%s`.`%s`;", to, tableName),
)
Expand Down

0 comments on commit 1803bbf

Please sign in to comment.