Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Chnage task_run_id to use INTEGER AUTOINCREMENT

天舟97fc476514c5
diff --git a/backend/scheduler/default_task_run_service.go b/backend/scheduler/default_task_run_service.go
index d870d844d0..c04c4cc822 100644
--- a/backend/scheduler/default_task_run_service.go
+++ b/backend/scheduler/default_task_run_service.go
@@ -111,17 +111,15 @@ func (s *DefaultTaskRunService) PatchTaskRunStatus(ctx context.Context, patch *T
func createTaskRun(ctx context.Context, tx *sql.Tx, create *TaskRunCreate) (*TaskRun, error) {
row, err := tx.QueryContext(ctx, `
INSERT INTO task_run (
- id,
task_id,
name,
`+"`status`,"+`
`+"`type`,"+`
payload
)
- VALUES (?, ?, ?, 'PENDING', ?, ?)
+ VALUES (?, ?, 'PENDING', ?, ?)
RETURNING id, created_ts, updated_ts, task_id, name, `+"`status`, `type`, payload"+`
`,
- create.ID,
create.TaskId,
create.Name,
create.Type,
@@ -163,7 +161,7 @@ func findTaskRunList(ctx context.Context, tx *sql.Tx, find *TaskRunFind) (_ []*T
rows, err := tx.QueryContext(ctx, `
SELECT
- id,
+ id,
created_ts,
updated_ts,
task_id,
diff --git a/backend/scheduler/scheduler.go b/backend/scheduler/scheduler.go
index 98561a5fd9..6dec499541 100644
--- a/backend/scheduler/scheduler.go
+++ b/backend/scheduler/scheduler.go
@@ -6,8 +6,6 @@ import (
"fmt"
"log"
"time"
-
- uuid "github.com/satori/go.uuid"
)
const (
@@ -81,7 +79,6 @@ func (s *Scheduler) Register(taskType string, executor Executor) {
func (s *Scheduler) Schedule(task Task) (*TaskRun, error) {
taskRunCreate := &TaskRunCreate{
- ID: uuid.NewV4().String(),
TaskId: task.ID,
Name: task.Name,
Type: task.Type,
diff --git a/backend/scheduler/task.go b/backend/scheduler/task.go
index 943bc9c897..8a90949b76 100644
--- a/backend/scheduler/task.go
+++ b/backend/scheduler/task.go
@@ -52,7 +52,6 @@ type TaskRun struct {
}
type TaskRunCreate struct {
- ID TaskRunId
TaskId TaskId
Name string
Type string
diff --git a/backend/store/migration/0001_init_schema.up.sql b/backend/store/migration/0001_init_schema.up.sql
index 32d201eb29..023c08f65d 100644
--- a/backend/store/migration/0001_init_schema.up.sql
+++ b/backend/store/migration/0001_init_schema.up.sql
@@ -499,7 +499,7 @@ END;
-- task run table stores the task run
CREATE TABLE task_run (
- id TEXT PRIMARY KEY,
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
task_id INTEGER NOT NULL REFERENCES task (id),
@@ -517,6 +517,11 @@ CREATE TABLE task_run (
payload TEXT NOT NULL DEFAULT ''
);
+INSERT INTO
+ sqlite_sequence (name, seq)
+VALUES
+ ('task_run', 1000);
+
CREATE TRIGGER IF NOT EXISTS `trigger_update_task_run_modification_time`
AFTER
UPDATE