database

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *sqlx.DB
View Source
var WriteMu *sync.Mutex

Functions

func AppSchemaVersion added in v0.2.0

func AppSchemaVersion() uint

func Backup added in v0.2.0

func Backup(db *sqlx.DB, backupPath string) error

Backup the database. If db is nil, then uses the existing database connection.

func DatabaseBackupPath added in v0.2.0

func DatabaseBackupPath() string

func Initialize

func Initialize(databasePath string) bool

Initialize initializes the database. If the database is new, then it performs a full migration to the latest schema version. Otherwise, any necessary migrations must be run separately using RunMigrations. Returns true if the database is new.

func NeedsMigration added in v0.2.0

func NeedsMigration() bool

Migrate the database

func Reset

func Reset(databasePath string) error

func RestoreFromBackup added in v0.2.0

func RestoreFromBackup(backupPath string) error

func RunMigrations added in v0.2.0

func RunMigrations() error

Migrate the database

func Version added in v0.2.0

func Version() uint

func WithInstance

func WithInstance(instance *Packr2Source) (source.Driver, error)

func WithTxn added in v0.4.0

func WithTxn(fn func(tx *sqlx.Tx) error) error

WithTxn executes the provided function within a transaction. It rolls back the transaction if the function returns an error, otherwise the transaction is committed.

Types

type Packr2Source

type Packr2Source struct {
	Box        *packr.Box
	Migrations *source.Migrations
}

func (*Packr2Source) Close

func (s *Packr2Source) Close() error

func (*Packr2Source) First

func (s *Packr2Source) First() (version uint, err error)

func (*Packr2Source) Next

func (s *Packr2Source) Next(version uint) (nextVersion uint, err error)

func (*Packr2Source) Open

func (s *Packr2Source) Open(url string) (source.Driver, error)

func (*Packr2Source) Prev

func (s *Packr2Source) Prev(version uint) (prevVersion uint, err error)

func (*Packr2Source) ReadDown

func (s *Packr2Source) ReadDown(version uint) (r io.ReadCloser, identifier string, err error)

func (*Packr2Source) ReadUp

func (s *Packr2Source) ReadUp(version uint) (r io.ReadCloser, identifier string, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳