db

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(url string) error

Create a new database based on the passed URL.

func Drop

func Drop(url string) error

Drop a database based on the passed URL.

func RunMigrations

func RunMigrations(fs embed.FS, conn *sql.DB) error

RunMigrations by checking in the migrations database table, each of the adapters take care of this.

func RunMigrationsDir

func RunMigrationsDir(dir string, conn *sql.DB) error

RunMigrationsDir receives a folder and a database URL to apply the migrations to the database.

func WithDriver

func WithDriver(name string) connectionOption

WithDriver allows to specify the driver to use driver defaults to postgres.

Types

type ConnFn

type ConnFn func() (*sql.DB, error)

ConnFn is the database connection builder function that will be used by the application based on the driver and connection string.

func ConnectionFn

func ConnectionFn(url string, opts ...connectionOption) ConnFn

ConnectionFn is the database connection builder function that will be used by the application based on the driver and connection string. It opens the connection only once and return the same connection on subsequent calls.

type Migrator added in v0.0.11

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

func NewMigrator added in v0.0.37

func NewMigrator(db *sql.DB) *Migrator

func (*Migrator) Run added in v0.0.11

func (m *Migrator) Run(timestamp, name, sql string) error

Run a particular database migration and inserting its timestamp on the migrations table.

func (*Migrator) Setup added in v0.0.11

func (m *Migrator) Setup() error

Setup the sqlite database to be ready to have the migrations inside.

Jump to

Keyboard shortcuts

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