schema

package
v0.0.0-...-919d8db Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: BSD-3-Clause Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecStatements

func ExecStatements(ctx context.Context, conn *sql.Conn, statements ...string) error

ExecStatements executes a list of SQL statements in order

Types

type Manager

type Manager struct {
	Schemata   *embed.FS
	SchemaName string
	Migrators  map[int]Migrator
}

func (*Manager) AllSchemas

func (m *Manager) AllSchemas() *Schemas

AllSchemas returns a schemas instance containing all embedded schemas.

func (*Manager) Init

func (m *Manager) Init(ctx context.Context, db *sqlite.DB, logf logger.Logf) (err error)

Init initializes the database schema if needed or performs migrations.

func (*Manager) LatestSchema

func (m *Manager) LatestSchema() []byte

LatestSchema returns the schema with the highest version.

func (*Manager) LatestSchemaVersion

func (m *Manager) LatestSchemaVersion() int

LatestSchemaVersion returns the highest schema version that is supported by the manager.

func (*Manager) MinSchemaVersion

func (m *Manager) MinSchemaVersion() int

MinSchemaVersion returns the minimum schema version that is supported by the manager. This is the lowest schema version that has a migrator. If there are no migrators, it returns the latest schema version.

func (*Manager) Schema

func (m *Manager) Schema(version int) string

Schema returns the schema for a specific version.

type Migrator

type Migrator func(ctx context.Context, conn *sql.Conn) error

A schema upgrader function takes a transaction and upgrades the schema from one version to the next.

type Schemas

type Schemas struct {
	Schemas []struct {
		// contains filtered or unexported fields
	}
}

Schemas is a slice of all embedded Schemas, sorted by version.

func (*Schemas) Len

func (s *Schemas) Len() int

Len returns the number of schemas.

Directories

Path Synopsis
sqlgen is a tool to generate SQL schema from Go struct types.
sqlgen is a tool to generate SQL schema from Go struct types.

Jump to

Keyboard shortcuts

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