golibmigrate

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 6 Imported by: 0

README

Golib Migrate

Note We are moving out from Gitlab. All packages are now migrated to github.com/golibs-starter/*. Please consider updating.

Migration solutions for Golang project.

Setup instruction

Base setup, see GoLib Instruction

Both go get and go mod are supported.

go get github.com/golibs-starter/golib-migrate
Usage

Using fx.Option to include dependencies for injection.

package main

import (
	"context"
	"github.com/golibs-starter/golib"
	"github.com/golibs-starter/golib-data"
	"github.com/golibs-starter/golib-migrate"
	"github.com/golibs-starter/golib/log"
	"go.uber.org/fx"
)

func main() {
	if err := fx.New(
		// Required options for migration
		golib.AppOpt(),
		golib.PropertiesOpt(),
		golib.LoggingOpt(),
		golibdata.DatasourceOpt(),

		// When you want to run migration
		golibmigrate.MigrationOpt(),
	).Start(context.Background()); err != nil {
		log.Fatal("Error when migrate database: ", err)
	}
}
Configuration
app:
    datasource:
        # Define the database driver.
        # Supports: mysql, postgres, sqlite
        driver: mysql
        host: localhost
        port: 3306
        database: sample
        username: root
        password: secret
        # Define location of migration files
        migrationSource: file://migrations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(migration *migrate.Migrate, props *migration.Properties) error

func MigrationOpt

func MigrationOpt() fx.Option

func ProvideMigrationDriverStrategy

func ProvideMigrationDriverStrategy(constructor interface{}) fx.Option

Types

type NewDriverResolverIn

type NewDriverResolverIn struct {
	fx.In
	Strategies []driver.Strategy `group:"migration_driver_strategy"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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