server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: Unlicense Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureMigrationTableExistsCh

func EnsureMigrationTableExistsCh(db *sqlx.DB) chan types.Done

EnsureMigrationTableExistsCh checks if the migrations table exists and creates it if it doesn't

func GetDB

func GetDB() *sqlx.DB

GetDB returns a singleton DB instance

func GetLiveMigrationInfoCh

func GetLiveMigrationInfoCh(db *sqlx.DB, migrationFs embed.FS) chan MigrationState

GetLiveMigrationInfoCh returns the latest migration version and the installed migration version

func GetMockDB

func GetMockDB() (*sqlx.DB, sqlmock.Sqlmock)

GetMockDB returns a mock DB for testing

func MigrateDownCh

func MigrateDownCh(db *sqlx.DB, migrationFs embed.FS) chan types.Done

MigrateDownCh migrates the database down to the previous version

func MigrateUpCh

func MigrateUpCh(db *sqlx.DB, migrationFs embed.FS) chan types.Done

MigrateUpCh migrates the database up to the latest version

func SetupServer

func SetupServer(engine *gin.Engine, db *sqlx.DB, templateFS embed.FS, staticFs embed.FS)

Types

type MigrationState

type MigrationState struct {
	AvailableVersion int
	InstalledVersion int
	Migrations       []migrationFileInfo
}

type MigrationsTable

type MigrationsTable struct {
	Version     int       `db:"version"`
	InstalledAt time.Time `db:"installed_at"`
}

Jump to

Keyboard shortcuts

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