feat: add Node SSR deployment transaction record

This commit is contained in:
2026-08-22 15:45:57 +08:00
parent 0f3e16ea41
commit ed80e2b656
2 changed files with 132 additions and 1 deletions
+18 -1
View File
@@ -17,7 +17,7 @@ import (
"github.com/ncruces/go-sqlite3/driver"
)
const schemaVersion = 2
const schemaVersion = 3
// schemaV1 SQLite 数据库的首版 schema,定义事务、步骤与事件三张核心表。
//
@@ -95,6 +95,21 @@ CREATE TABLE backend_container_deployment (
PRAGMA user_version = 2;
`
// schemaV3 新增 Node SSR 容器部署单例表。
const schemaV3 = `
CREATE TABLE node_ssr_container_deployment (
singleton_id INTEGER PRIMARY KEY CHECK (singleton_id = 1),
active_port INTEGER NOT NULL CHECK (active_port IN (18910, 28910)),
container_name TEXT NOT NULL,
image_digest TEXT NOT NULL,
container_id TEXT NOT NULL,
transaction_id TEXT NOT NULL REFERENCES transactions(id),
updated_at TEXT NOT NULL
) STRICT;
PRAGMA user_version = 3;
`
// Store 服务端 SQLite 事务记录。一个进程只应创建一个 Store。
//
// 它封装了底层 *sql.DB,并把单连接访问(MaxOpenConns/MaxIdleConns 均为 1)作为
@@ -222,6 +237,8 @@ func migrate(ctx context.Context, db *sql.DB) error {
script = schemaV1
case 2:
script = schemaV2
case 3:
script = schemaV3
default:
return fmt.Errorf("sqlite migration script is missing for version %d", nextVersion)
}