Documentation
¶
Overview ¶
Package database provides database connection and migration functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a database connection with migration capabilities.
func (*Database) Connection ¶
Connection returns the underlying sqlx database connection.
func (*Database) RegisterRepository ¶
RegisterRepository registers a repository in the database. If repository implements migrator interface, it will migrate when `Migrate` is called.
type Migration ¶
Migration represents a database migration with up and down SQL statements.
func ParseMigrations ¶
ParseMigrations parses SQL migration files from an fs.FS. Files must have .sql extension and contain -- +migrate Up marker. The -- +migrate Down marker is optional. Migration ID is derived from the filename without extension, unless overridden with -- +migrate ID: <custom_id> as the first marker. Only one ID override marker is allowed and it must appear before any other markers. Returns an error if ID marker appears after Up/Down markers or if multiple ID markers exist. Migrations are returned sorted lexicographically by filename.