migrations

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecInTx

func ExecInTx(
	db *sql.DB,
	opts *sql.TxOptions,
	initFn func(*sql.Tx) error,
	txFn func(*sql.Tx) (interface{}, error),
) (ret interface{}, err error)

ExecInTx executes a callback inside a sql transaction on the provided DB. The transaction is rolled back if any error is encountered. initFn is a callback to call before the main txFn, commonly used in our codebase to execute a CREATE TABLE IF NOT EXISTS. Copied from orc8r/cloud/go/sqorc/tx.go.

func GetAllKeysFromTable

func GetAllKeysFromTable(tx *sql.Tx, table string) ([]string, error)

func GetAllValuesFromTable

func GetAllValuesFromTable(tx *sql.Tx, table string) (map[string][]byte, error)

If the table DNE, log and return empty map

func GetEnvWithDefault

func GetEnvWithDefault(variable string, defaultValue string) string

func GetTableName

func GetTableName(networkId string, baseName string) string

func MigrateNetworkAgnosticServiceToBlobstore

func MigrateNetworkAgnosticServiceToBlobstore(nid, typ, oldTable, newTable string)

MigrateNetworkAgnosticServiceToBlobstore migrates a network-agnostic service's data from datastore to blobstore formats.

Schema migration:

  • Datastore has cols
  • key
  • value
  • generation_number
  • deleted
  • Blobstore has cols
  • network_id
  • type
  • key
  • value
  • version
  • Conversion (blobstore col <- datastore col)
  • network_id <- [nid parameter]
  • type <- [typ parameter]
  • key <- key
  • value <- value
  • version <- generation_number
  • n/a <- deleted

Types

This section is empty.

Directories

Path Synopsis
migration
DB migration script for the config service refactor.
DB migration script for the config service refactor.
migration
DB migration script to clean up old magmad config tables.
DB migration script to clean up old magmad config tables.

Jump to

Keyboard shortcuts

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