Documentation
¶
Overview ¶
Package db opens the selected persistent store, runs its embedded migrations, and wires the generated gorm/gen repositories' default query. Business code uses the typed repositories (internal/pkg/db/repositories) — never raw SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Driver Driver
Hostname string
Port int
Username string
Password string
Database string
IsSSL bool
SQLitePath string
SQLiteBusyTimeout time.Duration
// contains filtered or unexported fields
}
Config is the database connection config, mapped from the app config so the db package doesn't depend on the whole config struct.
type Driver ¶
type Driver string
Driver identifies the persistence implementation selected for one Chatz process.
type Handle ¶
Handle is an open database connection owned by its caller. The GORM handle backs the generated repositories; Close releases the underlying SQL pool.
func Connect ¶
Connect opens the configured database, runs its migrations, and sets the generated repositories' default query. The returned handle is owned by the caller — Close it on shutdown.
func (*Handle) MigrationStatus ¶
func (h *Handle) MigrationStatus(ctx context.Context) (MigrationStatus, error)
MigrationStatus reads the actual migration ledger after startup migrations have completed. It is diagnostics-only and does not mutate the database.
func (*Handle) PostgreSQL ¶
func (h *Handle) PostgreSQL() *postgresql.Postgresql
PostgreSQL returns the native connection for PostgreSQL-only maintenance operations, such as the migration reversibility integration test. It is nil for the SQLite driver; application code should use GormDB + repositories.
type MigrationStatus ¶
MigrationStatus is the database's applied schema position.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package migrations embeds the SQL migration files into the binary so the binary is self-contained (no directory to mount).
|
Package migrations embeds the SQL migration files into the binary so the binary is self-contained (no directory to mount). |
|
Package models holds the plain Go structs that gorm/gen generates type-safe repositories from.
|
Package models holds the plain Go structs that gorm/gen generates type-safe repositories from. |