Skip to content

Commit e16fb8b

Browse files
committed
1
1 parent b289c0d commit e16fb8b

4 files changed

Lines changed: 10 additions & 75 deletions

File tree

docs/plans/2026-03-18-worker-log-bigint-id.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
44
5-
**Goal:**`execution_logs.id` 改为数据库自增的整数主键,并同步代码与前端类型。
5+
**Goal:**`worker_run_log.id` 改为数据库自增的整数主键,并同步代码与前端类型。
66

77
**Architecture:** 不新增运行时迁移逻辑,默认由用户手动删除旧表后重新建表。后端将 `WorkerLog.ID` 改为 `int64` 自增主键,写入时不再生成 UUID,前端日志类型同步改为数字。
88

internal/db/worker_log_test.go

Lines changed: 0 additions & 65 deletions
This file was deleted.

internal/model/worker_log.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import "time"
55
// WorkerLog 表示函数执行日志。
66
type WorkerLog struct {
77
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
8-
WorkerID string `json:"worker_id" gorm:"column:worker_id;type:text;not null;index:idx_execution_logs_worker_created,priority:1"`
9-
RequestID string `json:"request_id" gorm:"column:request_id;type:text;not null;index:idx_execution_logs_request_id"`
8+
WorkerID string `json:"worker_id" gorm:"column:worker_id;type:text;not null;index:idx_worker_run_log_worker_created,priority:1"`
9+
RequestID string `json:"request_id" gorm:"column:request_id;type:text;not null;index:idx_worker_run_log_request_id"`
1010
Status int `json:"status" gorm:"column:status"`
1111
Stdin string `json:"stdin" gorm:"column:stdin;type:text"`
1212
Stdout string `json:"stdout" gorm:"column:stdout;type:text"`
1313
Stderr string `json:"stderr" gorm:"column:stderr;type:text"`
1414
Result string `json:"result" gorm:"column:result;type:text"`
1515
Error string `json:"error" gorm:"column:error;type:text"`
1616
DurationMS int64 `json:"duration_ms" gorm:"column:duration_ms"`
17-
CreatedAt time.Time `json:"created_at" gorm:"column:created_at;not null;index:idx_execution_logs_worker_created,priority:2;autoCreateTime:false"`
17+
CreatedAt time.Time `json:"created_at" gorm:"column:created_at;not null;index:idx_worker_run_log_worker_created,priority:2;autoCreateTime:false"`
1818
}
1919

2020
func (WorkerLog) TableName() string {
21-
return "execution_logs"
21+
return "worker_run_log"
2222
}

migrations/001_init.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CREATE TABLE worker (
99
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
1010
);
1111

12-
CREATE TABLE execution_logs (
12+
CREATE TABLE worker_run_log (
1313
id INTEGER PRIMARY KEY AUTOINCREMENT,
1414
worker_id TEXT NOT NULL,
1515
request_id TEXT NOT NULL,
@@ -23,8 +23,8 @@ CREATE TABLE execution_logs (
2323
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
2424
);
2525

26-
CREATE INDEX idx_execution_logs_worker_created
27-
ON execution_logs(worker_id, created_at);
26+
CREATE INDEX idx_worker_run_log_worker_created
27+
ON worker_run_log(worker_id, created_at);
2828

29-
CREATE INDEX idx_execution_logs_request_id
30-
ON execution_logs(request_id);
29+
CREATE INDEX idx_worker_run_log_request_id
30+
ON worker_run_log(request_id);

0 commit comments

Comments
 (0)