migrate

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 12 Imported by: 0

README

POSH Golang Migrate provider

Usage

Plugin
package main

import (
  // ...
  // import database drivers
  _ "github.com/golang-migrate/migrate/v4/database/pgx/v5"
  // import source drivers
  _ "github.com/golang-migrate/migrate/v4/source/file"
  // ...
)

type Plugin struct {
  l log.Logger
}

func New(l log.Logger) (plugin.Plugin, error) {
  var err error
  inst := &Plugin{
    l:        l,
    commands: command.Commands{},
  }

  // ...

  inst.commands.Add(migrate.NewCommand(l))

  // ...

  return inst, nil
}

Config
## Migrate
migrate:
  # https://github.com/golang-migrate/migrate/blob/master/README.md#migration-sources
  databases:
    local: pgx5://postgres:postgres@localhost:5432/admin?sslmode=disable
  # https://github.com/golang-migrate/migrate/blob/master/README.md#migration-sources
  sources:
    default: file://migrations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(l log.Logger, opts ...CommandOption) (*Command, error)

func (*Command) Complete

func (c *Command) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Command) Description

func (c *Command) Description() string

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, r *readline.Readline) error

func (*Command) Help

func (c *Command) Help(ctx context.Context, r *readline.Readline) string

func (*Command) Name

func (c *Command) Name() string

type CommandOption

type CommandOption func(*Command)

func CommandWithConfigKey

func CommandWithConfigKey(v string) CommandOption

func CommandWithName

func CommandWithName(v string) CommandOption

func CommandWithOnePassword added in v0.24.1

func CommandWithOnePassword(v *onepassword.OnePassword) CommandOption

type Config

type Config struct {
	SourcesMap   map[string]string `json:"sources" yaml:"sources" mapstructure:"sources"`
	DatabasesMap map[string]string `json:"databases" yaml:"databases" mapstructure:"databases"`
}

func (Config) Database

func (c Config) Database(name string) string

func (Config) Databases

func (c Config) Databases() []string

func (Config) Source

func (c Config) Source(name string) string

func (Config) Sources

func (c Config) Sources() []string

Jump to

Keyboard shortcuts

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