migrator

package
v8.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package migrator provides utilities for database migration management.

Index

Examples

Constants

View Source
const (
	DefaultOption option = iota
	MigratorOption
)

Define values for [option].

Variables

View Source
var (
	ErrExecSQL     = errors.New("locking: failed to execute SQL")
	ErrAcquireLock = errors.New("locking: failed to acquire advisory lock")
	ErrReleaseLock = errors.New("locking: failed to release advisory lock")
)

Functions

func GenerateLockKey added in v8.5.0

func GenerateLockKey(s string) int64

GenerateLockKey generates a lock key from a string.

See the benchmark results for performance comparisons between different hashing algorithms.

Example
package main

import (
	"fmt"

	"github.com/bartventer/gorm-multitenancy/v8/pkg/migrator"
)

func main() {
	key := migrator.GenerateLockKey("test")
	fmt.Printf("%d", key)
}
Output:

-439409999022904539

func OptionFromDB

func OptionFromDB(db *gorm.DB) (option, error)

OptionFromDB retrieves the migration option from the database. If the option is not found or is not of the correct type, it returns driver.ErrInvalidMigration.

func WithOption

func WithOption(opt option) func(*gorm.DB) *gorm.DB

WithOption sets the migration option for the database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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