Skip to main content

internal/migrate/planes.go

internal/migrate · 222 lines · 5 declarations · source

Declarations

const ControlRole, DataRole

const (
// ControlRole accesses the credential registry. Operator DDL uses the admin connection.
ControlRole = "taisce_control"
// DataRole serves project memory and cannot read credential secrets in control.
DataRole = "taisce_data"
)

One instance has separate control and memory database identities.

source

func EstablishPlanes

func EstablishPlanes(ctx context.Context, pool *pgxpool.Pool, controlPassword, dataPassword string) error

EstablishPlanes creates or reconciles the instance logins, control namespace and grants. It is an idempotent deployment operation requiring an administrative connection. DataRole serves all projects in the instance: authenticated application scope filters control reads, while foreign keys enforce project-consistent writes. Schema naming alone grants no confidentiality against a role with access to that schema. An owner/admin can change these rules.

source

func ensureRole

func ensureRole(ctx context.Context, on statements, name, password string) error

source

func quoteLiteral

func quoteLiteral(s string) string

quoteLiteral renders a string as a SQL literal, doubling any quote it contains.

source

func grantMemoryToDataPlane

func grantMemoryToDataPlane(ctx context.Context, pool statements, schema Schema) error

grantMemoryToDataPlane applies runtime privileges after memory migrations. It grants one instance namespace. An absent role is allowed for isolated migration fixtures without deployment-role provisioning privileges.

source