Documentation
¶
Overview ¶
Package sqlite implements SQLite-specific schema introspection, in-memory shadow validation, and the 12-step table rebuild engine.
Index ¶
- func AttachDatabases(ctx context.Context, dbtx dialect.DBTX, attach map[string]string) error
- func AttachMemorySchemas(ctx context.Context, dbtx dialect.DBTX, schemas []string) error
- func CompileInShadow(ctx context.Context, schemaSQL string) (*schema.Schema, error)
- func CompileInShadowSchemas(ctx context.Context, schemaSQL string, schemas []string) (map[string]*schema.Schema, error)
- func DetachDatabases(ctx context.Context, dbtx dialect.DBTX, names []string) error
- func Diff(live, desired *schema.Schema, filters scope.Filters) []plan.Step
- func DumpSchema(ctx context.Context, dbtx dialect.DBTX, schemaName string) (string, error)
- func GenerateSQLiteCreateTable(tbl *schema.Table) string
- func GenerateSQLiteRebuildPlan(liveTable, desiredTable *schema.Table, ...) (string, bool)
- func Inspect(ctx context.Context, dbtx dialect.DBTX) (*schema.Schema, error)
- func InspectSchema(ctx context.Context, dbtx dialect.DBTX, schemaName string) (*schema.Schema, error)
- func InspectSchemas(ctx context.Context, dbtx dialect.DBTX, schemas []string) (map[string]*schema.Schema, error)
- func NormalizeDefault(d string) string
- func NormalizeType(t string) string
- func Render(step plan.Step) ([]dialect.Stmt, error)
- type SQLite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachDatabases ¶
AttachDatabases runs ATTACH DATABASE for each schema→path entry on the pinned connection. Names are validated upstream; paths are bound as parameters. "main" must not appear — it is the already-open primary DB.
func AttachMemorySchemas ¶
AttachMemorySchemas attaches empty in-memory databases for each schema name other than "main". Used by shadow compilation so desired DDL can target attached schemas without touching live files.
func CompileInShadow ¶
CompileInShadow executes schemaSQL in an isolated in-memory SQLite database and returns the introspected schema.
func CompileInShadowSchemas ¶
func CompileInShadowSchemas(ctx context.Context, schemaSQL string, schemas []string) (map[string]*schema.Schema, error)
CompileInShadowSchemas compiles schemaSQL against a private :memory: connection with ATTACH ':memory:' AS name for every non-main target schema. Live filesystem paths are never opened — shadow attaches are empty in-memory databases so desired DDL compiles without mutating production files.
func DetachDatabases ¶
DetachDatabases runs DETACH DATABASE for each name (reverse order).
func DumpSchema ¶
DumpSchema extracts the canonical DDL SQL for all user objects from the SQLite catalog.
func GenerateSQLiteCreateTable ¶
GenerateSQLiteCreateTable constructs a standard SQLite CREATE TABLE statement.
func GenerateSQLiteRebuildPlan ¶
func GenerateSQLiteRebuildPlan(liveTable, desiredTable *schema.Table, refViews, refTriggers []*schema.UnmanagedObject) (string, bool)
GenerateSQLiteRebuildPlan generates the standard 12-step atomic table replacement plan, preserving and rebinding referencing views and triggers across table recreation.
func Inspect ¶
Inspect extracts the complete relational schema from the primary ("main") SQLite database on the connection.
func InspectSchema ¶
func InspectSchema(ctx context.Context, dbtx dialect.DBTX, schemaName string) (*schema.Schema, error)
InspectSchema extracts the relational schema from a named SQLite schema (e.g. "main" or an ATTACH DATABASE name). Catalog reads use schema.sqlite_schema and PRAGMA schema.table_xinfo.
func InspectSchemas ¶
func InspectSchemas(ctx context.Context, dbtx dialect.DBTX, schemas []string) (map[string]*schema.Schema, error)
InspectSchemas inspects each named schema (including attached databases) and returns a map keyed by schema name.
func NormalizeDefault ¶
NormalizeDefault standardizes default expressions in SQLite.
func NormalizeType ¶
NormalizeType standardizes SQLite types into canonical representations.
Types ¶
type SQLite ¶
type SQLite struct{}
SQLite implements the dialect.Dialect interface for SQLite.