Documentation ¶
Overview ¶
Package migration contains all the necessary code for the creation and population of the database.
Index ¶
- Constants
- func ExecuteSQLFile(filename string, args ...string) fn
- func Migrate(db *sql.DB, catalog string, configuration MigrationConfiguration) error
- func MigrateToNextVersion(tx *sql.Tx, nextVersion *int64, m Migrations, catalog string) error
- func NewMigrationContext(ctx context.Context) context.Context
- type MigrationConfiguration
- type Migrations
Constants ¶
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 ExecuteSQLFile ¶
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 ¶
func Migrate(db *sql.DB, catalog string, configuration MigrationConfiguration) 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 ¶
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.
Types ¶
type MigrationConfiguration ¶
type MigrationConfiguration interface {
GetOpenShiftClientApiUrl() string
}
type Migrations ¶
type Migrations []steps
Migrations defines all a collection of all the steps
func GetMigrations ¶
func GetMigrations(configuration MigrationConfiguration) 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!