Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package store is the workspace server's database: the schema (migrations), the queries (sqlc) and the migration runner.

After editing migrations/ or queries.sql:

go tool -modfile=tools/go.mod sqlc generate -f server/platform/store/sqlc.yaml

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, pool *pgxpool.Pool) error

Migrate brings the database schema to the latest version: sign-in's (schema auth) and the platform's.

Types

type AcceptInviteParams

type AcceptInviteParams struct {
	ID         string
	AcceptedAt *time.Time
	AcceptedBy *string
}

type AddAuditParams

type AddAuditParams struct {
	ActorID   string
	Action    string
	Target    string
	Detail    string
	CreatedAt time.Time
}

type AddDeployParams

type AddDeployParams struct {
	ServerID     string
	ProjectID    string
	Version      int32
	Signature    []byte
	SignerDevice string
	DeployedBy   string
	DeployedAt   time.Time
}

type AddDeviceEnvironmentParams

type AddDeviceEnvironmentParams struct {
	DeviceID          string
	UserID            string
	EnvID             string
	Project           string
	Kind              string
	Name              string
	Branch            string
	Phase             string
	Url               string
	Error             string
	ConfigVersion     int32
	Overrides         []string
	RejectedOverrides []string
	PendingVersion    int32
}

type AddKeyWrapParams

type AddKeyWrapParams struct {
	Generation int32
	DeviceID   string
	UserID     string
	Wrapped    []byte
	WrappedBy  string
	CreatedAt  time.Time
}

type AddMemberParams

type AddMemberParams struct {
	UserID   string
	Role     string
	JoinedAt time.Time
}

type AddOwnerParams

type AddOwnerParams struct {
	UserID   string
	JoinedAt time.Time
}

type AddProjectVersionParams

type AddProjectVersionParams struct {
	ProjectID string
	Version   int32
	Config    string
	AuthorID  string
	Message   string
	CreatedAt time.Time
}

type AddWorkspaceKeyParams

type AddWorkspaceKeyParams struct {
	Generation int32
	PublicKey  string
	CreatedBy  string
	CreatedAt  time.Time
}

type Audit

type Audit struct {
	ID        int64
	ActorID   string
	Action    string
	Target    string
	Detail    string
	CreatedAt time.Time
}

type AuditRow

type AuditRow struct {
	ID        int64
	ActorID   string
	Action    string
	Target    string
	Detail    string
	CreatedAt time.Time
	Actor     string
}

type CertifySigningKeyParams

type CertifySigningKeyParams struct {
	DeviceID    string
	UserID      string
	Certificate []byte
}

type ClearDeviceEnvironmentsParams

type ClearDeviceEnvironmentsParams struct {
	DeviceID string
	UserID   string
}

type CreateInviteParams

type CreateInviteParams struct {
	ID        string
	CodeHash  []byte
	Email     string
	Role      string
	CreatedBy string
	CreatedAt time.Time
	ExpiresAt time.Time
}

type CreateProjectParams

type CreateProjectParams struct {
	ID        string
	Name      string
	CreatedBy string
	CreatedAt time.Time
}

type CreateServerParams

type CreateServerParams struct {
	ID          string
	Name        string
	CreatedBy   string
	CreatedAt   time.Time
	JoinHash    *string
	JoinExpires *time.Time
}

type CreateWorkspaceParams

type CreateWorkspaceParams struct {
	ID         string
	Name       string
	OwnerEmail string
	CreatedAt  time.Time
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteDeviceWrapsParams

type DeleteDeviceWrapsParams struct {
	DeviceID string
	UserID   string
}

type DeleteProjectRoleParams

type DeleteProjectRoleParams struct {
	ProjectID string
	UserID    string
}

type DeleteSecretParams

type DeleteSecretParams struct {
	ProjectID string
	Name      string
}

type DeleteServerEnvironmentParams

type DeleteServerEnvironmentParams struct {
	ServerID  string
	ProjectID string
}

type Device

type Device struct {
	DeviceID     string
	UserID       string
	Name         string
	AgentVersion string
	LastSeen     time.Time
}

type DeviceEnvironment

type DeviceEnvironment struct {
	DeviceID          string
	UserID            string
	EnvID             string
	Project           string
	Kind              string
	Name              string
	Branch            string
	Phase             string
	Url               string
	Error             string
	ConfigVersion     int32
	Overrides         []string
	RejectedOverrides []string
	PendingVersion    int32
}

type DeviceKey

type DeviceKey struct {
	DeviceID  string
	UserID    string
	Name      string
	PublicKey string
	CreatedAt time.Time
}

type DeviceKeyParams

type DeviceKeyParams struct {
	DeviceID string
	UserID   string
}

type DevicesRow

type DevicesRow struct {
	DeviceID     string
	UserID       string
	Name         string
	AgentVersion string
	LastSeen     time.Time
	Email        string
}

type DomainTakenParams

type DomainTakenParams struct {
	Domain    string
	ServerID  string
	ProjectID string
}

type Invite

type Invite struct {
	ID         string
	CodeHash   []byte
	Email      string
	Role       string
	CreatedBy  string
	CreatedAt  time.Time
	ExpiresAt  time.Time
	AcceptedAt *time.Time
	AcceptedBy *string
	RevokedAt  *time.Time
}

type JoinServerParams

type JoinServerParams struct {
	ID        string
	TokenHash *string
	JoinedAt  *time.Time
}

type KeyWrap

type KeyWrap struct {
	Generation int32
	DeviceID   string
	UserID     string
	Wrapped    []byte
	WrappedBy  string
	CreatedAt  time.Time
}

type KeyWrapParams

type KeyWrapParams struct {
	Generation int32
	DeviceID   string
	UserID     string
}

type LastDeployParams

type LastDeployParams struct {
	ServerID  string
	ProjectID string
}

type LastDeployRow

type LastDeployRow struct {
	ServerID     string
	ProjectID    string
	Seq          int64
	Version      int32
	Signature    []byte
	SignerDevice string
	DeployedBy   string
	DeployedAt   time.Time
	Deployer     string
}

type MayEnterParams

type MayEnterParams struct {
	Email     string
	ExpiresAt time.Time
}

type Member

type Member struct {
	UserID   string
	Role     string
	JoinedAt time.Time
}

type MembersRow

type MembersRow struct {
	UserID   string
	Role     string
	JoinedAt time.Time
	Email    string
}

type OpenInvitesForParams

type OpenInvitesForParams struct {
	Email     string
	ExpiresAt time.Time
}

type OpenInvitesRow

type OpenInvitesRow struct {
	ID         string
	CodeHash   []byte
	Email      string
	Role       string
	CreatedBy  string
	CreatedAt  time.Time
	ExpiresAt  time.Time
	AcceptedAt *time.Time
	AcceptedBy *string
	RevokedAt  *time.Time
	InvitedBy  string
}

type PendingDevicesRow

type PendingDevicesRow struct {
	DeviceID  string
	UserID    string
	Name      string
	PublicKey string
	Email     string
}

type ProductionDeploy

type ProductionDeploy struct {
	ServerID     string
	ProjectID    string
	Seq          int64
	Version      int32
	Signature    []byte
	SignerDevice string
	DeployedBy   string
	DeployedAt   time.Time
}

type Project

type Project struct {
	ID        string
	Name      string
	CreatedBy string
	CreatedAt time.Time
	Version   int32
}

type ProjectMember

type ProjectMember struct {
	ProjectID string
	UserID    string
	Role      string
}

type ProjectRolesRow

type ProjectRolesRow struct {
	ProjectID string
	UserID    string
	Role      string
	Project   string
}

type ProjectSecretsRow

type ProjectSecretsRow struct {
	ProjectID      string
	Name           string
	Generation     int32
	Ciphertext     []byte
	UpdatedBy      string
	UpdatedAt      time.Time
	UpdatedByEmail string
}

type ProjectVersion

type ProjectVersion struct {
	ProjectID    string
	Version      int32
	Config       string
	AuthorID     string
	Message      string
	CreatedAt    time.Time
	Signature    []byte
	SignerDevice string
}

type ProjectVersionParams

type ProjectVersionParams struct {
	ProjectID string
	Version   int32
}

type ProjectVersionRow

type ProjectVersionRow struct {
	ProjectID    string
	Version      int32
	Config       string
	AuthorID     string
	Message      string
	CreatedAt    time.Time
	Signature    []byte
	SignerDevice string
	Author       string
}

type ProjectVersionsParams

type ProjectVersionsParams struct {
	ProjectID string
	Limit     int32
}

type ProjectVersionsRow

type ProjectVersionsRow struct {
	Version   int32
	Message   string
	CreatedAt time.Time
	Author    string
	Signed    bool
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AcceptInvite

func (q *Queries) AcceptInvite(ctx context.Context, arg AcceptInviteParams) error

func (*Queries) AddAudit

func (q *Queries) AddAudit(ctx context.Context, arg AddAuditParams) error

func (*Queries) AddDeploy

func (q *Queries) AddDeploy(ctx context.Context, arg AddDeployParams) error

func (*Queries) AddDeviceEnvironment

func (q *Queries) AddDeviceEnvironment(ctx context.Context, arg AddDeviceEnvironmentParams) error

func (*Queries) AddKeyWrap

func (q *Queries) AddKeyWrap(ctx context.Context, arg AddKeyWrapParams) error

func (*Queries) AddMember

func (q *Queries) AddMember(ctx context.Context, arg AddMemberParams) error

func (*Queries) AddOwner

func (q *Queries) AddOwner(ctx context.Context, arg AddOwnerParams) (int64, error)

func (*Queries) AddProjectVersion

func (q *Queries) AddProjectVersion(ctx context.Context, arg AddProjectVersionParams) error

func (*Queries) AddWorkspaceKey

func (q *Queries) AddWorkspaceKey(ctx context.Context, arg AddWorkspaceKeyParams) error

func (*Queries) Audit

func (q *Queries) Audit(ctx context.Context, limit int32) ([]AuditRow, error)

func (*Queries) CertifySigningKey

func (q *Queries) CertifySigningKey(ctx context.Context, arg CertifySigningKeyParams) error

func (*Queries) ClearDeviceEnvironments

func (q *Queries) ClearDeviceEnvironments(ctx context.Context, arg ClearDeviceEnvironmentsParams) error

func (*Queries) CreateInvite

func (q *Queries) CreateInvite(ctx context.Context, arg CreateInviteParams) (Invite, error)

func (*Queries) CreateProject

func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error)

func (*Queries) CreateServer

func (q *Queries) CreateServer(ctx context.Context, arg CreateServerParams) error

func (*Queries) CreateWorkspace

func (q *Queries) CreateWorkspace(ctx context.Context, arg CreateWorkspaceParams) error

func (*Queries) DeleteDeviceWraps

func (q *Queries) DeleteDeviceWraps(ctx context.Context, arg DeleteDeviceWrapsParams) error

func (*Queries) DeleteOldWraps

func (q *Queries) DeleteOldWraps(ctx context.Context, generation int32) error

func (*Queries) DeleteProject

func (q *Queries) DeleteProject(ctx context.Context, id string) error

func (*Queries) DeleteProjectMembersOf

func (q *Queries) DeleteProjectMembersOf(ctx context.Context, userID string) error

func (*Queries) DeleteProjectRole

func (q *Queries) DeleteProjectRole(ctx context.Context, arg DeleteProjectRoleParams) error

func (*Queries) DeleteSecret

func (q *Queries) DeleteSecret(ctx context.Context, arg DeleteSecretParams) (int64, error)

func (*Queries) DeleteServerEnvironment

func (q *Queries) DeleteServerEnvironment(ctx context.Context, arg DeleteServerEnvironmentParams) error

func (*Queries) DeviceEnvironments

func (q *Queries) DeviceEnvironments(ctx context.Context) ([]DeviceEnvironment, error)

func (*Queries) DeviceKey

func (q *Queries) DeviceKey(ctx context.Context, arg DeviceKeyParams) (DeviceKey, error)

func (*Queries) Devices

func (q *Queries) Devices(ctx context.Context) ([]DevicesRow, error)

func (*Queries) DomainTaken

func (q *Queries) DomainTaken(ctx context.Context, arg DomainTakenParams) (bool, error)

func (*Queries) Invite

func (q *Queries) Invite(ctx context.Context, id string) (Invite, error)

func (*Queries) JoinServer

func (q *Queries) JoinServer(ctx context.Context, arg JoinServerParams) error

func (*Queries) KeyWrap

func (q *Queries) KeyWrap(ctx context.Context, arg KeyWrapParams) (KeyWrap, error)

func (*Queries) LastDeploy

func (q *Queries) LastDeploy(ctx context.Context, arg LastDeployParams) (LastDeployRow, error)

func (*Queries) MayEnter

func (q *Queries) MayEnter(ctx context.Context, arg MayEnterParams) (*bool, error)

func (*Queries) Member

func (q *Queries) Member(ctx context.Context, userID string) (Member, error)

func (*Queries) Members

func (q *Queries) Members(ctx context.Context) ([]MembersRow, error)

func (*Queries) OpenInvites

func (q *Queries) OpenInvites(ctx context.Context, expiresAt time.Time) ([]OpenInvitesRow, error)

func (*Queries) OpenInvitesFor

func (q *Queries) OpenInvitesFor(ctx context.Context, arg OpenInvitesForParams) ([]Invite, error)

func (*Queries) PendingDevices

func (q *Queries) PendingDevices(ctx context.Context, generation int32) ([]PendingDevicesRow, error)

func (*Queries) ProjectByName

func (q *Queries) ProjectByName(ctx context.Context, name string) (Project, error)

func (*Queries) ProjectByNameForUpdate

func (q *Queries) ProjectByNameForUpdate(ctx context.Context, name string) (Project, error)

func (*Queries) ProjectRoles

func (q *Queries) ProjectRoles(ctx context.Context) ([]ProjectRolesRow, error)

func (*Queries) ProjectSecrets

func (q *Queries) ProjectSecrets(ctx context.Context, projectID string) ([]ProjectSecretsRow, error)

func (*Queries) ProjectVersion

func (q *Queries) ProjectVersion(ctx context.Context, arg ProjectVersionParams) (ProjectVersionRow, error)

func (*Queries) ProjectVersions

func (q *Queries) ProjectVersions(ctx context.Context, arg ProjectVersionsParams) ([]ProjectVersionsRow, error)

func (*Queries) Projects

func (q *Queries) Projects(ctx context.Context) ([]Project, error)

func (*Queries) RemoveMember

func (q *Queries) RemoveMember(ctx context.Context, userID string) error

func (*Queries) RemoveProjectRole

func (q *Queries) RemoveProjectRole(ctx context.Context, arg RemoveProjectRoleParams) (int64, error)

func (*Queries) RevokeInvite

func (q *Queries) RevokeInvite(ctx context.Context, arg RevokeInviteParams) error

func (*Queries) ServerByJoin

func (q *Queries) ServerByJoin(ctx context.Context, joinHash *string) (Server, error)

func (*Queries) ServerByName

func (q *Queries) ServerByName(ctx context.Context, name string) (Server, error)

func (*Queries) ServerByToken

func (q *Queries) ServerByToken(ctx context.Context, tokenHash *string) (Server, error)

func (*Queries) ServerEnvironment

func (q *Queries) ServerEnvironment(ctx context.Context, arg ServerEnvironmentParams) (ServerEnvironment, error)

func (*Queries) ServerEnvironments

func (q *Queries) ServerEnvironments(ctx context.Context) ([]ServerEnvironmentsRow, error)

func (*Queries) Servers

func (q *Queries) Servers(ctx context.Context) ([]ServersRow, error)

func (*Queries) SetKeyGeneration

func (q *Queries) SetKeyGeneration(ctx context.Context, keyGeneration int32) error

func (*Queries) SetMemberRole

func (q *Queries) SetMemberRole(ctx context.Context, arg SetMemberRoleParams) error

func (*Queries) SetProjectRole

func (q *Queries) SetProjectRole(ctx context.Context, arg SetProjectRoleParams) error

func (*Queries) SetProjectVersion

func (q *Queries) SetProjectVersion(ctx context.Context, arg SetProjectVersionParams) error

func (*Queries) SetSecret

func (q *Queries) SetSecret(ctx context.Context, arg SetSecretParams) error

func (*Queries) SetTrustRoot

func (q *Queries) SetTrustRoot(ctx context.Context, arg SetTrustRootParams) error

func (*Queries) SignProjectVersion

func (q *Queries) SignProjectVersion(ctx context.Context, arg SignProjectVersionParams) error

func (*Queries) SigningKey

func (q *Queries) SigningKey(ctx context.Context, arg SigningKeyParams) (SigningKey, error)

func (*Queries) SigningKeys

func (q *Queries) SigningKeys(ctx context.Context) ([]SigningKeysRow, error)

func (*Queries) UpsertDevice

func (q *Queries) UpsertDevice(ctx context.Context, arg UpsertDeviceParams) error

func (*Queries) UpsertDeviceKey

func (q *Queries) UpsertDeviceKey(ctx context.Context, arg UpsertDeviceKeyParams) error

func (*Queries) UpsertServerEnvironment

func (q *Queries) UpsertServerEnvironment(ctx context.Context, arg UpsertServerEnvironmentParams) error

func (*Queries) UpsertSigningKey

func (q *Queries) UpsertSigningKey(ctx context.Context, arg UpsertSigningKeyParams) error

func (*Queries) UpsertUser

func (q *Queries) UpsertUser(ctx context.Context, arg UpsertUserParams) error

func (*Queries) UserByEmail

func (q *Queries) UserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) UserProjectRoles

func (q *Queries) UserProjectRoles(ctx context.Context, userID string) ([]UserProjectRolesRow, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

func (*Queries) Workspace

func (q *Queries) Workspace(ctx context.Context) (Workspace, error)

func (*Queries) WorkspaceAdmin

func (q *Queries) WorkspaceAdmin(ctx context.Context) (User, error)

func (*Queries) WorkspaceDeviceKeys

func (q *Queries) WorkspaceDeviceKeys(ctx context.Context) ([]DeviceKey, error)

func (*Queries) WorkspaceForUpdate

func (q *Queries) WorkspaceForUpdate(ctx context.Context) (Workspace, error)

func (*Queries) WorkspaceKey

func (q *Queries) WorkspaceKey(ctx context.Context) (WorkspaceKey, error)

func (*Queries) WorkspaceSecrets

func (q *Queries) WorkspaceSecrets(ctx context.Context) ([]WorkspaceSecretsRow, error)

type RemoveProjectRoleParams

type RemoveProjectRoleParams struct {
	ProjectID string
	UserID    string
}

type RevokeInviteParams

type RevokeInviteParams struct {
	ID        string
	RevokedAt *time.Time
}

type Secret

type Secret struct {
	ProjectID  string
	Name       string
	Generation int32
	Ciphertext []byte
	UpdatedBy  string
	UpdatedAt  time.Time
}

type Server

type Server struct {
	ID          string
	Name        string
	CreatedBy   string
	CreatedAt   time.Time
	JoinHash    *string
	JoinExpires *time.Time
	TokenHash   *string
	JoinedAt    *time.Time
}

type ServerEnvironment

type ServerEnvironment struct {
	ServerID     string
	ProjectID    string
	Kind         string
	Domain       string
	Signature    []byte
	SignerDevice string
	CreatedBy    string
	CreatedAt    time.Time
}

type ServerEnvironmentParams

type ServerEnvironmentParams struct {
	ServerID  string
	ProjectID string
}

type ServerEnvironmentsRow

type ServerEnvironmentsRow struct {
	ServerID     string
	ProjectID    string
	Kind         string
	Domain       string
	Signature    []byte
	SignerDevice string
	CreatedBy    string
	CreatedAt    time.Time
	Server       string
	Project      string
	Creator      string
}

type ServersRow

type ServersRow struct {
	ID           string
	Name         string
	CreatedBy    string
	CreatedAt    time.Time
	JoinHash     *string
	JoinExpires  *time.Time
	TokenHash    *string
	JoinedAt     *time.Time
	LastSeen     *time.Time
	AgentVersion *string
	Projects     []string
}

type SetMemberRoleParams

type SetMemberRoleParams struct {
	UserID string
	Role   string
}

type SetProjectRoleParams

type SetProjectRoleParams struct {
	ProjectID string
	UserID    string
	Role      string
}

type SetProjectVersionParams

type SetProjectVersionParams struct {
	ID      string
	Version int32
}

type SetSecretParams

type SetSecretParams struct {
	ProjectID  string
	Name       string
	Generation int32
	Ciphertext []byte
	UpdatedBy  string
	UpdatedAt  time.Time
}

type SetTrustRootParams

type SetTrustRootParams struct {
	TrustRoot       []byte
	TrustRootDevice string
	TrustRootUser   string
}

type SignProjectVersionParams

type SignProjectVersionParams struct {
	ProjectID    string
	Version      int32
	Signature    []byte
	SignerDevice string
}

type SigningKey

type SigningKey struct {
	DeviceID    string
	UserID      string
	Name        string
	PublicKey   []byte
	Certificate []byte
	CreatedAt   time.Time
}

type SigningKeyParams

type SigningKeyParams struct {
	DeviceID string
	UserID   string
}

type SigningKeysRow

type SigningKeysRow struct {
	DeviceID    string
	UserID      string
	Name        string
	PublicKey   []byte
	Certificate []byte
	CreatedAt   time.Time
	Email       string
	Role        string
}

type UpsertDeviceKeyParams

type UpsertDeviceKeyParams struct {
	DeviceID  string
	UserID    string
	Name      string
	PublicKey string
	CreatedAt time.Time
}

type UpsertDeviceParams

type UpsertDeviceParams struct {
	DeviceID     string
	UserID       string
	Name         string
	AgentVersion string
	LastSeen     time.Time
}

type UpsertServerEnvironmentParams

type UpsertServerEnvironmentParams struct {
	ServerID     string
	ProjectID    string
	Kind         string
	Domain       string
	Signature    []byte
	SignerDevice string
	CreatedBy    string
	CreatedAt    time.Time
}

type UpsertSigningKeyParams

type UpsertSigningKeyParams struct {
	DeviceID  string
	UserID    string
	Name      string
	PublicKey []byte
	CreatedAt time.Time
}

type UpsertUserParams

type UpsertUserParams struct {
	ID     string
	Email  string
	SeenAt time.Time
}

type User

type User struct {
	ID     string
	Email  string
	SeenAt time.Time
}

type UserProjectRolesRow

type UserProjectRolesRow struct {
	ProjectID string
	UserID    string
	Role      string
	Project   string
}

type Workspace

type Workspace struct {
	ID              string
	Name            string
	OwnerEmail      string
	CreatedAt       time.Time
	KeyGeneration   int32
	TrustRoot       []byte
	TrustRootDevice string
	TrustRootUser   string
}

type WorkspaceKey

type WorkspaceKey struct {
	Generation int32
	PublicKey  string
	CreatedBy  string
	CreatedAt  time.Time
}

type WorkspaceSecretsRow

type WorkspaceSecretsRow struct {
	ProjectID  string
	Name       string
	Generation int32
	Ciphertext []byte
	UpdatedBy  string
	UpdatedAt  time.Time
	Project    string
}

Jump to

Keyboard shortcuts

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