补齐任务部署结果持久化与查询接口
保存批量部署每台服务器的执行结果,新增数据库迁移、仓储查询和任务部署结果接口,并补充应用与仓储测试。
This commit is contained in:
1 parent
253f2bd824
commit
126cb6d566
11 files changed
+330
-1
No files matched your search
@@ -17,6 +17,7 @@ import (
|
||||
//go:embed migrations/sqlite/0013_history_scope.sql migrations/mysql/0013_history_scope.sql migrations/postgres/0013_history_scope.sql
|
||||
//go:embed migrations/sqlite/0014_project_members.sql migrations/mysql/0014_project_members.sql migrations/postgres/0014_project_members.sql
|
||||
//go:embed migrations/sqlite/0015_task_idempotency.sql migrations/mysql/0015_task_idempotency.sql migrations/postgres/0015_task_idempotency.sql
|
||||
//go:embed migrations/sqlite/0016_task_deployment_results.sql migrations/mysql/0016_task_deployment_results.sql migrations/postgres/0016_task_deployment_results.sql
|
||||
var migrationFiles embed.FS
|
||||
|
||||
func Migrate(ctx context.Context, db *sql.DB, driver string) error {
|
||||
@@ -41,7 +42,7 @@ func Migrate(ctx context.Context, db *sql.DB, driver string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
const latestMigrationVersion = 15
|
||||
const latestMigrationVersion = 16
|
||||
|
||||
// currentMigrationVersion 在执行业务迁移前拒绝新版数据库及不连续的迁移历史。
|
||||
func currentMigrationVersion(ctx context.Context, db *sql.DB) (int, error) {
|
||||
@@ -223,6 +224,8 @@ func migrationName(version int) string {
|
||||
return "project_members"
|
||||
case 15:
|
||||
return "task_idempotency"
|
||||
case 16:
|
||||
return "task_deployment_results"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE task_deployment_results (
|
||||
task_id VARCHAR(36) NOT NULL,
|
||||
attempt_id VARCHAR(36) NOT NULL,
|
||||
attempt_number INT NOT NULL,
|
||||
result_index INT NOT NULL,
|
||||
server_id VARCHAR(36) NOT NULL,
|
||||
server_name VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
backup_id VARCHAR(128) NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (task_id, attempt_id, result_index),
|
||||
INDEX idx_task_deployment_results_task_id (task_id)
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE task_deployment_results (
|
||||
task_id VARCHAR(36) NOT NULL,
|
||||
attempt_id VARCHAR(36) NOT NULL,
|
||||
attempt_number INTEGER NOT NULL,
|
||||
result_index INTEGER NOT NULL,
|
||||
server_id VARCHAR(36) NOT NULL,
|
||||
server_name VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
backup_id VARCHAR(128) NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (task_id, attempt_id, result_index)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_task_deployment_results_task_id ON task_deployment_results(task_id);
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE task_deployment_results (
|
||||
task_id TEXT NOT NULL,
|
||||
attempt_id TEXT NOT NULL,
|
||||
attempt_number INTEGER NOT NULL,
|
||||
result_index INTEGER NOT NULL,
|
||||
server_id TEXT NOT NULL,
|
||||
server_name TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
backup_id TEXT NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (task_id, attempt_id, result_index)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_task_deployment_results_task_id ON task_deployment_results(task_id);
|
||||
Reference in new issue
Block a user