sqlitedb

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 11 Imported by: 0 modules, 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

Overview

Package sqlitedb provisions per-tenant SQLite databases. Each tenant gets a file at {DataDir}/{db_name}.db. "Provisioning" reduces to:

  1. Open (= create) the SQLite file with our PRAGMA defaults.
  2. Run the api_config + users migrations when auth is enabled.
  3. Insert a JWT secret if api_config is empty.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provisioner

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

Provisioner manages tenant SQLite files under cfg.DataDir.

func New

func New(cfg *config.Config) *Provisioner

func (*Provisioner) DropDatabase

func (p *Provisioner) DropDatabase(ctx context.Context, dbName string) error

DropDatabase removes the SQLite file and its WAL/SHM siblings.

func (*Provisioner) EnsureJWTSecret

func (p *Provisioner) EnsureJWTSecret(ctx context.Context, dbName string) error

EnsureJWTSecret inserts a jwt_secret row into api_config if empty. Idempotent.

func (*Provisioner) EnsureTenant

func (p *Provisioner) EnsureTenant(ctx context.Context, dbName string) (bool, error)

EnsureTenant creates the SQLite file if it does not exist. Returns true if the file is newly created (so callers can run first-publish hooks).

func (*Provisioner) OpenTenant

func (p *Provisioner) OpenTenant(ctx context.Context, dbName string) (*sql.DB, error)

OpenTenant is a small public entry point used by the DDL package.

func (*Provisioner) Ping

func (p *Provisioner) Ping(ctx context.Context) error

Ping verifies that DataDir exists and is writable.

func (*Provisioner) RunTenantMigrations

func (p *Provisioner) RunTenantMigrations(ctx context.Context, dbName string) error

RunTenantMigrations creates the api_config and users tables used by auth.

Directories

Path Synopsis
Package ddl is SupaCraft's SQLite DDL engine.
Package ddl is SupaCraft's SQLite DDL engine.

Jump to

Keyboard shortcuts

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