Documentation
¶
Overview ¶
Package sqlitedb provisions per-tenant SQLite databases. Each tenant gets a file at {DataDir}/{db_name}.db. "Provisioning" reduces to:
- Open (= create) the SQLite file with our PRAGMA defaults.
- Run the api_config + users migrations when auth is enabled.
- Insert a JWT secret if api_config is empty.
Index ¶
- type Provisioner
- func (p *Provisioner) DropDatabase(ctx context.Context, dbName string) error
- func (p *Provisioner) EnsureJWTSecret(ctx context.Context, dbName string) error
- func (p *Provisioner) EnsureTenant(ctx context.Context, dbName string) (bool, error)
- func (p *Provisioner) OpenTenant(ctx context.Context, dbName string) (*sql.DB, error)
- func (p *Provisioner) Ping(ctx context.Context) error
- func (p *Provisioner) RunTenantMigrations(ctx context.Context, dbName string) error
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 ¶
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 ¶
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.