Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
3956819c
Commit
3956819c
authored
Jan 05, 2026
by
shaw
Browse files
fix: 数据迁移时长增加到10分钟
parent
168aa578
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/internal/repository/ent.go
View file @
3956819c
...
@@ -56,7 +56,7 @@ func InitEnt(cfg *config.Config) (*ent.Client, *sql.DB, error) {
...
@@ -56,7 +56,7 @@ func InitEnt(cfg *config.Config) (*ent.Client, *sql.DB, error) {
// 确保数据库 schema 已准备就绪。
// 确保数据库 schema 已准备就绪。
// SQL 迁移文件是 schema 的权威来源(source of truth)。
// SQL 迁移文件是 schema 的权威来源(source of truth)。
// 这种方式比 Ent 的自动迁移更可控,支持复杂的迁移场景。
// 这种方式比 Ent 的自动迁移更可控,支持复杂的迁移场景。
migrationCtx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
6
0
*
time
.
Second
)
migrationCtx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
1
0
*
time
.
Minute
)
defer
cancel
()
defer
cancel
()
if
err
:=
applyMigrationsFS
(
migrationCtx
,
drv
.
DB
(),
migrations
.
FS
);
err
!=
nil
{
if
err
:=
applyMigrationsFS
(
migrationCtx
,
drv
.
DB
(),
migrations
.
FS
);
err
!=
nil
{
_
=
drv
.
Close
()
// 迁移失败时关闭驱动,避免资源泄露
_
=
drv
.
Close
()
// 迁移失败时关闭驱动,避免资源泄露
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment