Documentation
¶
Index ¶
- Variables
- func AppSchemaVersion() uint
- func Backup(db *sqlx.DB, backupPath string) error
- func DatabaseBackupPath() string
- func Initialize(databasePath string) bool
- func NeedsMigration() bool
- func Reset(databasePath string) error
- func RestoreFromBackup(backupPath string) error
- func RunMigrations() error
- func Version() uint
- func WithInstance(instance *Packr2Source) (source.Driver, error)
- func WithTxn(fn func(tx *sqlx.Tx) error) error
- type Packr2Source
- func (s *Packr2Source) Close() error
- func (s *Packr2Source) First() (version uint, err error)
- func (s *Packr2Source) Next(version uint) (nextVersion uint, err error)
- func (s *Packr2Source) Open(url string) (source.Driver, error)
- func (s *Packr2Source) Prev(version uint) (prevVersion uint, err error)
- func (s *Packr2Source) ReadDown(version uint) (r io.ReadCloser, identifier string, err error)
- func (s *Packr2Source) ReadUp(version uint) (r io.ReadCloser, identifier string, err error)
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
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 ¶
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 RestoreFromBackup ¶ added in v0.2.0
func WithInstance ¶
func WithInstance(instance *Packr2Source) (source.Driver, error)
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) 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)
Click to show internal directories.
Click to hide internal directories.