migrations

package
v3.19.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package migrations implements database migrations.

Index

Constants

This section is empty.

Variables

All is a list of all database migrations.

Functions

func Apply

func Apply(
	ctx context.Context,
	transact func(context.Context, func(*gorm.DB) error) error,
	migrations ...Migration,
) error

Apply applies the list of migrations on the database connection.

Types

type EUIBlocksIndex added in v3.18.0

type EUIBlocksIndex struct{}

EUIBlocksIndex removes the unique index constraint from `type` field.

func (EUIBlocksIndex) Apply added in v3.18.0

func (m EUIBlocksIndex) Apply(_ context.Context, db *gorm.DB) error

Apply implements Migration.

func (EUIBlocksIndex) Name added in v3.18.0

func (EUIBlocksIndex) Name() string

Name implements Migration.

func (EUIBlocksIndex) Rollback added in v3.18.0

func (m EUIBlocksIndex) Rollback(_ context.Context, db *gorm.DB) error

Rollback implements migration. It recreates the removed "eui_block_index".

type EntityContacts

type EntityContacts struct{}

EntityContacts sets the contacts of entities to their first collaborator.

func (EntityContacts) Apply

func (EntityContacts) Apply(ctx context.Context, db *gorm.DB) error

Apply implements Migration.

func (EntityContacts) Name

func (EntityContacts) Name() string

Name implements Migration.

func (EntityContacts) Rollback

func (EntityContacts) Rollback(context.Context, *gorm.DB) error

Rollback implements migration. For the EntityContacts migration this is a no-op.

type Migration

type Migration interface {
	// Name returns the name of the migration.
	Name() string
	// Apply applies the changes imposed by the migration to the given database (or transaction).
	Apply(context.Context, *gorm.DB) error
	// Rollback rolls back the changes imposed by the migration to the given database (or transaction).
	Rollback(context.Context, *gorm.DB) error
}

Migration abstracts away the logic of a migration.

Jump to

Keyboard shortcuts

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