...

Package sqlserver

import "github.com/golang-migrate/migrate/v4/database/sqlserver"
Overview
Index

Overview ▾

Variables

var (
    ErrNilConfig                 = fmt.Errorf("no config")
    ErrNoDatabaseName            = fmt.Errorf("no database name")
    ErrNoSchema                  = fmt.Errorf("no schema")
    ErrDatabaseDirty             = fmt.Errorf("database is dirty")
    ErrMultipleAuthOptionsPassed = fmt.Errorf("both password and useMsi=true were passed.")
)

DefaultMigrationsTable is the name of the migrations table in the database

var DefaultMigrationsTable = "schema_migrations"

func WithInstance

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error)

WithInstance returns a database instance from an already created database connection.

Note that the deprecated `mssql` driver is not supported. Please use the newer `sqlserver` driver.

type Config

Config for database

type Config struct {
    MigrationsTable string
    DatabaseName    string
    SchemaName      string
}

type SQLServer

SQL Server connection

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

func (*SQLServer) Close

func (ss *SQLServer) Close() error

Close the database connection

func (*SQLServer) Drop

func (ss *SQLServer) Drop() error

Drop all tables from the database.

func (*SQLServer) Lock

func (ss *SQLServer) Lock() error

Lock creates an advisory local on the database to prevent multiple migrations from running at the same time.

func (*SQLServer) Open

func (ss *SQLServer) Open(url string) (database.Driver, error)

Open a connection to the database.

func (*SQLServer) Run

func (ss *SQLServer) Run(migration io.Reader) error

Run the migrations for the database

func (*SQLServer) SetVersion

func (ss *SQLServer) SetVersion(version int, dirty bool) error

SetVersion for the current database

func (*SQLServer) Unlock

func (ss *SQLServer) Unlock() error

Unlock froms the migration lock from the database

func (*SQLServer) Version

func (ss *SQLServer) Version() (version int, dirty bool, err error)

Version of the current database state