sqlbundle

package module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: AGPL-3.0 Imports: 19 Imported by: 4

README

SQLBundle Build Status

SQLBundle is a database migration tool. Manage your database schema by creating incremental SQL changes.

Install

Currently, sqlbundle just support oracle and postgresql, so for a fully version of the binary, use:

$ make release

Please noted that fully version just support Linux. For other version such as postgresql-only or none-db , binary supports Linux, macOS and Windows

For a lite version of the binary without DB connection dependent commands, use the exclusive build tags:

$ make dev-nodb #for only current os

#or

$ make release-nodb #for all OS

Usage

Usage: sqlbundle COMMAND [OPTIONS]

COMMAND:
  init          Init new sql project
  create        Create a new sql file
  install       Download and install dependencies into deps directory
  pack          Packing
  clean         Remove build directory
  publish       Deploy package to repository
  list          List all migrations file
  version       Print version of sql-bundle
  upgrade       Upgrade database to latest version
  downgrade     Downgrade database to previous version or any specific version
  help          Print usage info

Examples:

Options:
  -artifact string
    	artifact name
  -db-connection string
    	connection string of database
  -db-driver string
    	database driver
  -file string
    	name of sql file
  -force
    	force to delete before install
  -group string
    	group name
  -pass string
    	repository credential
  -repo string
    	address of repository
  -user string
    	repository credential
  -verbose
    	print more log
  -version string
    	version of database
  -workdir string
    	working directory

License

Licensed under GNU Affero General Public License Version 3

Documentation

Index

Constants

View Source
const (
	ParserStarted   int = iota // 0
	ParserUpBegin              // 1
	ParserDownBegin            // 3
	ParserClosed
)
View Source
const PACKAGE_JSON = "package.json"
View Source
const TIME_FORMAT = "20060102150405"

Variables

This section is empty.

Functions

func Handle

func Handle(command string, bundle SQLBundle) error

func OpenDBWithDriver

func OpenDBWithDriver(driver string, dbstring string) (*sql.DB, error)

OpenDBWithDriver creates a connection a database, and modifies goose internals to be compatible with the supplied driver by calling SetDialect.

func SetDialect

func SetDialect(d string) error

SetDialect sets the SQLDialect

func SetLogWriter

func SetLogWriter(writer io.Writer)

func SetVersion added in v1.2.1

func SetVersion(v string)

Types

type Argument

type Argument struct {
	Version    string
	Group      string
	Artifact   string
	WorkDir    string
	Filename   string
	Force      bool
	Repository string
	Username   string
	Password   string
	DBDriver   string
	DBString   string
}

type Command

type Command struct {
	Command string
	Argument
}

func ReadArgument

func ReadArgument() (cmd Command, err error)

type DbHistory

type DbHistory struct {
	Id         int
	Version    string
	DepName    string
	DepVersion string
	File       string
	CheckSum   string
	Timestamp  time.Time
}

func QueryDatabaseHistories

func QueryDatabaseHistories(db *sql.DB) ([]DbHistory, error)

type DbVersion

type DbVersion struct {
	Id        int
	Version   string
	Timestamp time.Time
}

func QueryDatabaseVersions

func QueryDatabaseVersions(db *sql.DB) ([]DbVersion, error)

type MigrationSQL

type MigrationSQL struct {
	AppVersion string
	Group      string
	Artifact   string
	Version    string
	FilePath   string
	FileName   string
}

type MigrationScript

type MigrationScript struct {
	AppVersion string
	Group      string
	Artifact   string
	Version    string
	FilePath   string
	FileName   string
	NextScript *MigrationScript
	Ignore     bool
}

func (*MigrationScript) ForEach added in v1.3.0

func (ms *MigrationScript) ForEach(f func(m MigrationScript) error) error

func (*MigrationScript) ListAll

func (ms *MigrationScript) ListAll()

type OracleDialect

type OracleDialect struct{}

type PackageJSON

type PackageJSON struct {
	GroupId      string   `json:"group"`
	ArtifactId   string   `json:"artifact"`
	Version      string   `json:"version"`
	Dependencies []string `json:"dependencies"`
}

func ReadPackageJSON

func ReadPackageJSON(file string) (config PackageJSON, err error)

type PostgresDialect

type PostgresDialect struct{}

type SQLBundle

type SQLBundle struct {
	Argument
	Config     *PackageJSON
	WorkingDir string
	SourceDir  string
	BuildDir   string
	DepsDir    string
	ConfigFile string
}

func NewSQLBundle

func NewSQLBundle(arg Argument) (bundle SQLBundle, err error)

func (*SQLBundle) Clean

func (sb *SQLBundle) Clean() error

func (*SQLBundle) Create

func (sb *SQLBundle) Create() error

func (*SQLBundle) Downgrade

func (sb *SQLBundle) Downgrade() error

func (*SQLBundle) Init

func (sb *SQLBundle) Init() error

func (*SQLBundle) Install

func (sb *SQLBundle) Install() error

func (*SQLBundle) ListMigrations

func (sb *SQLBundle) ListMigrations() error

func (*SQLBundle) Pack

func (sb *SQLBundle) Pack() error

func (*SQLBundle) Publish

func (sb *SQLBundle) Publish() error

func (*SQLBundle) ReadVersion

func (sb *SQLBundle) ReadVersion() string

func (*SQLBundle) Upgrade

func (sb *SQLBundle) Upgrade() error

type SQLDialect

type SQLDialect interface {
	// contains filtered or unexported methods
}

func GetDialect

func GetDialect() SQLDialect

type SQLiteDialect added in v1.5.0

type SQLiteDialect struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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