migration

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package migration contains all the necessary code for the creation and population of the database.

Index

Constants

View Source
const AdvisoryLockID = 42

AdvisoryLockID is a random number that should be used within the application by anybody who wants to modify the "version" table.

Variables

This section is empty.

Functions

func BootstrapWorkItemLinking added in v0.0.2

func BootstrapWorkItemLinking(ctx context.Context, linkCatRepo *link.GormWorkItemLinkCategoryRepository, spaceRepo *space.GormRepository, linkTypeRepo *link.GormWorkItemLinkTypeRepository) error

BootstrapWorkItemLinking makes sure the database is populated with the correct work item link stuff (e.g. category and some basic types)

func ExecuteSQLFile added in v0.0.2

func ExecuteSQLFile(filename string, args ...string) fn

ExecuteSQLFile loads the given filename from the packaged SQL files and executes it on the given database. Golang text/template module is used to handle all the optional arguments passed to the sql files

func Migrate added in v0.0.2

func Migrate(db *sql.DB, catalog string) error

Migrate executes the required migration of the database on startup. For each successful migration, an entry will be written into the "version" table, that states when a certain version was reached.

func MigrateToNextVersion added in v0.0.2

func MigrateToNextVersion(tx *sql.Tx, nextVersion *int64, m Migrations, catalog string) error

MigrateToNextVersion migrates the database to the nextVersion. If the database is already at nextVersion or higher, the nextVersion will be set to the actual next version.

func NewMigrationContext added in v0.0.2

func NewMigrationContext(ctx context.Context) context.Context

NewMigrationContext aims to create a new goa context where to initialize the request and req_id context keys. NOTE: We need this function to initialize the goa.ContextRequest

func PopulateCommonTypes added in v0.0.2

func PopulateCommonTypes(ctx context.Context, db *gorm.DB, witr *workitem.GormWorkItemTypeRepository) error

PopulateCommonTypes makes sure the database is populated with the correct types (e.g. bug etc.)

Types

type Migrations added in v0.0.2

type Migrations []steps

Migrations defines all a collection of all the steps

func GetMigrations added in v0.0.2

func GetMigrations() Migrations

GetMigrations returns the migrations all the migrations we have. Add your own migration to the end of this function. IMPORTANT: ALWAYS APPEND AT THE END AND DON'T CHANGE THE ORDER OF MIGRATIONS!

Jump to

Keyboard shortcuts

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