feat: add admin scenario operations
This commit is contained in:
@@ -31,6 +31,25 @@ enum GatewayBuildStatus {
|
||||
SUCCEEDED
|
||||
}
|
||||
|
||||
enum GatewayOperationType {
|
||||
RESET
|
||||
START
|
||||
STOP
|
||||
}
|
||||
|
||||
enum GatewayOperationStatus {
|
||||
QUEUED
|
||||
RUNNING
|
||||
SUCCEEDED
|
||||
FAILED
|
||||
CANCELLED
|
||||
}
|
||||
|
||||
enum GatewaySourceMode {
|
||||
BRANCH
|
||||
COMMIT
|
||||
}
|
||||
|
||||
model AppUser {
|
||||
id String @id @default(uuid())
|
||||
loginId String @unique @map("login_id")
|
||||
@@ -71,11 +90,36 @@ model GatewayProfile {
|
||||
meta Json @default(dbgenerated("'{}'::jsonb"))
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
operations GatewayOperation[]
|
||||
|
||||
@@unique([profile, scenario])
|
||||
@@map("gateway_profile")
|
||||
}
|
||||
|
||||
model GatewayOperation {
|
||||
id String @id @default(uuid())
|
||||
profileName String @map("profile_name")
|
||||
profile GatewayProfile @relation(fields: [profileName], references: [profileName], onDelete: Cascade)
|
||||
type GatewayOperationType
|
||||
status GatewayOperationStatus @default(QUEUED)
|
||||
sourceMode GatewaySourceMode? @map("source_mode")
|
||||
sourceRef String? @map("source_ref")
|
||||
resolvedCommitSha String? @map("resolved_commit_sha")
|
||||
payload Json @default(dbgenerated("'{}'::jsonb"))
|
||||
reason String?
|
||||
requestedBy String @map("requested_by")
|
||||
scheduledAt DateTime? @map("scheduled_at")
|
||||
startedAt DateTime? @map("started_at")
|
||||
completedAt DateTime? @map("completed_at")
|
||||
error String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@index([status, scheduledAt, createdAt])
|
||||
@@index([profileName, createdAt])
|
||||
@@map("gateway_operation")
|
||||
}
|
||||
|
||||
model SystemSetting {
|
||||
id Int @id @default(1) @map("no")
|
||||
notice String @default("") @map("notice")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
CREATE TYPE "GatewayOperationType" AS ENUM ('RESET', 'START', 'STOP');
|
||||
CREATE TYPE "GatewayOperationStatus" AS ENUM ('QUEUED', 'RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED');
|
||||
CREATE TYPE "GatewaySourceMode" AS ENUM ('BRANCH', 'COMMIT');
|
||||
|
||||
CREATE TABLE "gateway_operation" (
|
||||
"id" TEXT NOT NULL,
|
||||
"profile_name" TEXT NOT NULL,
|
||||
"type" "GatewayOperationType" NOT NULL,
|
||||
"status" "GatewayOperationStatus" NOT NULL DEFAULT 'QUEUED',
|
||||
"source_mode" "GatewaySourceMode",
|
||||
"source_ref" TEXT,
|
||||
"resolved_commit_sha" TEXT,
|
||||
"payload" JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
"reason" TEXT,
|
||||
"requested_by" TEXT NOT NULL,
|
||||
"scheduled_at" TIMESTAMP(3),
|
||||
"started_at" TIMESTAMP(3),
|
||||
"completed_at" TIMESTAMP(3),
|
||||
"error" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "gateway_operation_pkey" PRIMARY KEY ("id"),
|
||||
CONSTRAINT "gateway_operation_profile_name_fkey"
|
||||
FOREIGN KEY ("profile_name") REFERENCES "gateway_profile"("profile_name")
|
||||
ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX "gateway_operation_status_scheduled_at_created_at_idx"
|
||||
ON "gateway_operation"("status", "scheduled_at", "created_at");
|
||||
CREATE INDEX "gateway_operation_profile_name_created_at_idx"
|
||||
ON "gateway_operation"("profile_name", "created_at");
|
||||
CREATE UNIQUE INDEX "gateway_operation_one_active_per_profile_idx"
|
||||
ON "gateway_operation"("profile_name")
|
||||
WHERE "status" IN ('QUEUED', 'RUNNING');
|
||||
Reference in New Issue
Block a user