db

package module
v0.0.0-...-a8afb48 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

Config holds database configuration

func NewConfig

func NewConfig() *Config

NewConfig creates a new database configuration from environment variables

type DB

type DB struct {
	*gorm.DB
}

DB wraps the database connection

func Connect

func Connect(config *Config) (*DB, error)

Connect establishes a database connection

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection

type Migration

type Migration struct {
	Version  int
	UpFile   string
	DownFile string
}

Migration represents a database migration

type Migrator

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

Migrator handles database migrations

func NewMigrator

func NewMigrator(dbURL string) (*Migrator, error)

NewMigrator creates a new migrator instance

func (*Migrator) LoadMigrations

func (m *Migrator) LoadMigrations(dir string) error

LoadMigrations loads migration files from the migrations directory

func (*Migrator) MigrateDown

func (m *Migrator) MigrateDown() error

MigrateDown rolls back the last migration

func (*Migrator) MigrateUp

func (m *Migrator) MigrateUp() error

MigrateUp runs all pending migrations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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