db

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CreateMigrationTable string = `
	CREATE TABLE IF NOT EXISTS migration (
		name TEXT NOT NULL PRIMARY KEY,
		created_at INTEGER NOT NULL
	);
`
View Source
const DeleteMigrationEntry string = `
	DELETE FROM migration WHERE name = ?
`
View Source
const FindMigrationEntry string = `
	SELECT name FROM migration WHERE name = ?
`
View Source
const NewMigrationEntry string = `
	INSERT INTO migration (name, created_at) VALUES (?, ?)
`

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

func GetDatabase added in v0.1.4

func GetDatabase() *Database

func NewDatabase

func NewDatabase(config *config.Database) *Database

func (*Database) GetLevelDB

func (db *Database) GetLevelDB(name string) *leveldb.DB

func (*Database) GetSQLite added in v0.1.3

func (db *Database) GetSQLite(name string) *SQLite

func (*Database) RevertMigrations added in v0.1.3

func (db *Database) RevertMigrations() error

func (*Database) RunMigrations added in v0.1.3

func (db *Database) RunMigrations() error

type SQLMigration added in v0.1.3

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

func NewSQLMigration added in v0.1.3

func NewSQLMigration(name string, upQuery string, downQuery string) SQLMigration

type SQLite added in v0.1.3

type SQLite struct {
	Db *sql.DB
	// contains filtered or unexported fields
}

SQLite struct definition

func (*SQLite) AddMigration added in v0.1.3

func (s *SQLite) AddMigration(migration ...SQLMigration)

AddMigration adds SQLMigration to migrations, can pass array of migrations

func (*SQLite) Migrations added in v0.1.3

func (s *SQLite) Migrations() []SQLMigration

Migrations return migrations array

func (*SQLite) RevertMigrations added in v0.1.3

func (s *SQLite) RevertMigrations() error

RevertMigrations revert all migrations in reverse order, from the last one to first

func (*SQLite) RunMigrations added in v0.1.3

func (s *SQLite) RunMigrations() error

RunMigrations run migrations - from first one to last

Jump to

Keyboard shortcuts

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