sql

package
v1.0.0-rc.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Table creation
	QueryInitSourcesTable            = "InitSourcesTable"
	QueryInitSinksTable              = "InitSinksTable"
	QueryInitUsersTable              = "InitUsersTable"
	QueryInitVHostsTable             = "InitVHostsTable"
	QueryInitWorkersTable            = "InitWorkersTable"
	QueryInitLogsTable               = "InitLogsTable"
	QueryInitWorkflowsTable          = "InitWorkflowsTable"
	QueryInitWorkflowNodeStatesTable = "InitWorkflowNodeStatesTable"
	QueryInitWebhookRequestsTable    = "InitWebhookRequestsTable"
	QueryInitSettingsTable           = "InitSettingsTable"
	QueryInitAuditLogsTable          = "InitAuditLogsTable"
	QueryInitSchemasTable            = "InitSchemasTable"
	QueryInitMessageTraceStepsTable  = "InitMessageTraceStepsTable"
	QueryInitWorkflowVersionsTable   = "InitWorkflowVersionsTable"
	QueryInitOutboxTable             = "InitOutboxTable"
	QueryInitWorkspacesTable         = "InitWorkspacesTable"
	QueryInitPluginsTable            = "InitPluginsTable"
	QueryInitApprovalsTable          = "InitApprovalsTable"

	// Upserts
	QueryUpdateNodeState = "UpdateNodeState"
	QuerySaveSetting     = "SaveSetting"

	// Sources
	QueryListSources        = "ListSources"
	QueryCountSources       = "CountSources"
	QueryCreateSource       = "CreateSource"
	QueryUpdateSource       = "UpdateSource"
	QueryUpdateSourceStatus = "UpdateSourceStatus"
	QueryUpdateSourceState  = "UpdateSourceState"
	QueryDeleteSource       = "DeleteSource"
	QueryGetSource          = "GetSource"

	// Sinks
	QueryListSinks        = "ListSinks"
	QueryCountSinks       = "CountSinks"
	QueryCreateSink       = "CreateSink"
	QueryUpdateSink       = "UpdateSink"
	QueryUpdateSinkStatus = "UpdateSinkStatus"
	QueryDeleteSink       = "DeleteSink"
	QueryGetSink          = "GetSink"

	// Users
	QueryListUsers            = "ListUsers"
	QueryCountUsers           = "CountUsers"
	QueryCreateUser           = "CreateUser"
	QueryUpdateUser           = "UpdateUser"
	QueryUpdateUserNoPassword = "UpdateUserNoPassword"
	QueryDeleteUser           = "DeleteUser"
	QueryGetUser              = "GetUser"
	QueryGetUserByUsername    = "GetUserByUsername"
	QueryGetUserByEmail       = "GetUserByEmail"

	// VHosts
	QueryListVHosts  = "ListVHosts"
	QueryCountVHosts = "CountVHosts"
	QueryCreateVHost = "CreateVHost"
	QueryUpdateVHost = "UpdateVHost"
	QueryDeleteVHost = "DeleteVHost"
	QueryGetVHost    = "GetVHost"

	// Workflows
	QueryListWorkflows        = "ListWorkflows"
	QueryCountWorkflows       = "CountWorkflows"
	QueryCreateWorkflow       = "CreateWorkflow"
	QueryUpdateWorkflow       = "UpdateWorkflow"
	QueryUpdateWorkflowStatus = "UpdateWorkflowStatus"
	QueryUpdateWorkflowStats  = "UpdateWorkflowStats"
	QueryDeleteWorkflow       = "DeleteWorkflow"
	QueryGetWorkflow          = "GetWorkflow"
	QueryAcquireLease         = "AcquireLease"
	QueryRenewLease           = "RenewLease"
	QueryReleaseLease         = "ReleaseLease"

	// Workspaces
	QueryListWorkspaces  = "ListWorkspaces"
	QueryCreateWorkspace = "CreateWorkspace"
	QueryDeleteWorkspace = "DeleteWorkspace"
	QueryGetWorkspace    = "GetWorkspace"

	// Workers
	QueryListWorkers     = "ListWorkers"
	QueryCountWorkers    = "CountWorkers"
	QueryCreateWorker    = "CreateWorker"
	QueryUpdateWorker    = "UpdateWorker"
	QueryUpdateHeartbeat = "UpdateHeartbeat"
	QueryDeleteWorker    = "DeleteWorker"
	QueryGetWorker       = "GetWorker"

	// Logs
	QueryListLogs   = "ListLogs"
	QueryCountLogs  = "CountLogs"
	QueryCreateLog  = "CreateLog"
	QueryDeleteLogs = "DeleteLogs"

	// Settings
	QueryGetSetting = "GetSetting"

	// Audit Logs
	QueryCreateAuditLog     = "CreateAuditLog"
	QueryListAuditLogs      = "ListAuditLogs"
	QueryCountAuditLogs     = "CountAuditLogs"
	QueryPurgeAuditLogs     = "PurgeAuditLogs"
	QueryPurgeMessageTraces = "PurgeMessageTraces"

	// Webhook Requests
	QueryCreateWebhookRequest  = "CreateWebhookRequest"
	QueryListWebhookRequests   = "ListWebhookRequests"
	QueryCountWebhookRequests  = "CountWebhookRequests"
	QueryGetWebhookRequest     = "GetWebhookRequest"
	QueryDeleteWebhookRequests = "DeleteWebhookRequests"

	// Form Submissions
	QueryInitFormSubmissionsTable   = "InitFormSubmissionsTable"
	QueryCreateFormSubmission       = "CreateFormSubmission"
	QueryListFormSubmissions        = "ListFormSubmissions"
	QueryCountFormSubmissions       = "CountFormSubmissions"
	QueryGetFormSubmission          = "GetFormSubmission"
	QueryUpdateFormSubmissionStatus = "UpdateFormSubmissionStatus"
	QueryDeleteFormSubmissions      = "DeleteFormSubmissions"

	// Schemas
	QueryListSchemas     = "ListSchemas"
	QueryListAllSchemas  = "ListAllSchemas"
	QueryGetSchema       = "GetSchema"
	QueryGetLatestSchema = "GetLatestSchema"
	QueryCreateSchema    = "CreateSchema"

	// Tracing
	QueryRecordTraceStep   = "RecordTraceStep"
	QueryGetMessageTrace   = "GetMessageTrace"
	QueryListMessageTraces = "ListMessageTraces"

	// Workflow Versioning
	QueryCreateWorkflowVersion = "CreateWorkflowVersion"
	QueryListWorkflowVersions  = "ListWorkflowVersions"
	QueryGetWorkflowVersion    = "GetWorkflowVersion"

	// Outbox
	QueryCreateOutboxItem = "CreateOutboxItem"
	QueryListOutboxItems  = "ListOutboxItems"
	QueryDeleteOutboxItem = "DeleteOutboxItem"
	QueryUpdateOutboxItem = "UpdateOutboxItem"

	// Marketplace
	QueryListPlugins     = "ListPlugins"
	QueryGetPlugin       = "GetPlugin"
	QueryCreatePlugin    = "CreatePlugin"
	QueryUpdatePlugin    = "UpdatePlugin"
	QueryInstallPlugin   = "InstallPlugin"
	QueryUninstallPlugin = "UninstallPlugin"

	// Approvals
	QueryListApprovals        = "ListApprovals"
	QueryCountApprovals       = "CountApprovals"
	QueryCreateApproval       = "CreateApproval"
	QueryGetApproval          = "GetApproval"
	QueryUpdateApprovalStatus = "UpdateApprovalStatus"
	QueryDeleteApproval       = "DeleteApproval"

	QueryInitSuspendedMessagesTable = "InitSuspendedMessagesTable"
	QueryCreateSuspendedMessage     = "CreateSuspendedMessage"
	QueryListSuspendedMessages      = "ListSuspendedMessages"
	QueryDeleteSuspendedMessage     = "DeleteSuspendedMessage"
)
View Source
const (
	// SchemaFingerprintKey names the settings row holding the applied schema.
	SchemaFingerprintKey = "hermod.schema_fingerprint"

	// SchemaAppliedAtKey names the settings row holding when it was applied.
	SchemaAppliedAtKey = "hermod.schema_applied_at"

	// SchemaVersionKey names the settings row holding the schema version.
	SchemaVersionKey = "hermod.schema_version"
)

Recording which schema a database is running.

There is no versioned migration system here: Init creates the tables it knows about and autoMigrate adds any columns that are missing. That is a deliberate simplification, but it left "does this database match this binary?" with no answer at all — and a schema left half-applied by a failed migration indistinguishable from a complete one.

So a fingerprint of the expected schema is written after a run that fully succeeds, and only then. Three questions become answerable from the database itself:

	SELECT value FROM settings WHERE key = 'hermod.schema_fingerprint';

  - what last applied a schema here, by comparing it with SchemaFingerprint()
  - whether the binary has been downgraded, because the values differ
  - whether the last upgrade finished, because a failed migration leaves the
    previous value in place

It is a fingerprint rather than a version number because there is nothing to number: no migration files, no ordering, and no down migrations. What it can honestly report is "the same schema" or "a different one".

Variables

View Source
var ErrSchemaFromTheFuture = errors.New("metadata schema is newer than this binary understands")

ErrSchemaFromTheFuture is returned when the database was migrated by a release newer than this binary.

Functions

func NewSQLStorage

func NewSQLStorage(db *sql.DB, driver string) storage.Storage

func SchemaFingerprint

func SchemaFingerprint() string

SchemaFingerprint returns a stable digest of the schema this binary expects.

It covers every CREATE TABLE the code defines, which is the same set autoMigrate reconciles, so adding a table or a column changes it. The statements are sorted first because Go iterates maps in a random order, and a fingerprint that varied between two runs of the same binary would report a schema change on every restart.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL