db

package
v0.1.44 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMigrations

func ApplyMigrations(tableName string, migrations []string, databasePath string) error

ApplyMigrations runs all the `migrations` on the sqlite3 database which is stored at the `databasePath`; since migrations are tied to tables, it's also requested that the `tableName` is provided

func Check added in v0.1.0

func Check(atPath string) error

Check performs a check whether the file at path `atPath` is already an initialised database

func Init

func Init(atPath string) error

Init initialises a local disk sqlite3 database for storage of incoming data

func InitTable

func InitTable(tableName string, connection *sql.DB) error

InitTable creates 2 tables, one named `tableName` and the other named `tableName`_migrations using the provided `connection`; this way of doing things distributes the migrations so that each table is independently migratable and hence independently removable

func IsMigrationAppliedAndValid

func IsMigrationAppliedAndValid(
	tableName string,
	migrationIndex int,
	migrationScript string,
	connection *sql.DB,
) (bool, error)

IsMigrationAppliedAndValid performs a check on whether the provided migration already exists in the database

func NewConnection

func NewConnection(databasePath string) (*sql.DB, error)

NewConnection creates a new database connection to the sqlite3 database located at `databasePath`

func RunMigration

func RunMigration(
	tableName string,
	migrationIndex int,
	migrationScript string,
	connection *sql.DB,
) error

RunMigration applies a single migration; this function assumes all database migrations are upward moving so design your migrations as such

Types

This section is empty.

Jump to

Keyboard shortcuts

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