studio

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package studio serves melange studio: a local, read-only web console over a melange-managed database. It is a presentation layer over calls the CLI already makes (GetDeployedModel, Checker.Explain, Checker.Expand); see specs/proposals/STUDIO.md. Two calls create objects in pg_temp inside a transaction that is always rolled back: what-if Explain (whatif.go), and Explain and Expand on a database migrated without their functions (sqlapi.Trace).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadOnlyDSN

func ReadOnlyDSN(dsn string) (string, error)

ReadOnlyDSN returns dsn with default_transaction_read_only=on set as a connection runtime parameter, so every statement the console runs is in a read-only transaction. Accepts URL and key=value forms.

func SetLatestRelease

func SetLatestRelease(v string)

SetLatestRelease records a newer release ("0.9.7") for the top bar. The check runs in the CLI, server-side, so the page itself never calls out.

func VerifyReadOnly

func VerifyReadOnly(ctx context.Context, db *sql.DB) error

VerifyReadOnly fails unless the connection really is read-only, so a driver that ignored the runtime parameter cannot silently leave writes enabled.

Types

type Server

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

Server holds the one database connection the console talks to.

func New

func New(db *sql.DB, dbSchema, env, schemaPath string) *Server

New returns a Server over db. env is the active environment name, shown in the page header; empty means the base config. schemaPath may be empty.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the console's routes, wrapped in a Host check.

func (*Server) SetExposure added in v0.11.0

func (s *Server) SetExposure(exposure *migrator.Exposure)

SetExposure sets the configured SQL API exposure (the sql section of melange.yaml) that the Health page compares with the recorded one and predicts migrate with, as melange doctor does. Nil, the default, keeps the recorded one.

Jump to

Keyboard shortcuts

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