package
3.5.4+incompatible
Repository: https://github.com/darkdna/migrate.git
Documentation: pkg.go.dev

# README

MySQL

mysql://user:password@tcp(host:port)/dbname?query

URL QueryWithInstance ConfigDescription
x-migrations-tableMigrationsTableName of the migrations table
dbnameDatabaseNameThe name of the database to connect to
userThe user to sign in as
passwordThe user's password
hostThe host to connect to.
portThe port to bind to.
tlsTLS / SSL encrypted connection parameter; see go-sql-driver. Use any name (e.g. migrate) if you want to use a custom TLS config (x-tls- queries).
x-tls-caThe location of the CA (certificate authority) file.
x-tls-certThe location of the client certicicate file. Must be used with x-tls-key.
x-tls-keyThe location of the private key file. Must be used with x-tls-cert.
x-tls-insecure-skip-verifyWhether or not to use SSL (true|false)

Use with existing client

If you use the MySQL driver with existing database client, you must create the client with parameter multiStatements=true:

package main

import (
    "database/sql"
    
    _ "github.com/go-sql-driver/mysql"
    "github.com/golang-migrate/migrate"
    "github.com/golang-migrate/migrate/database/mysql"
    _ "github.com/golang-migrate/migrate/source/file"
)

func main() {
    db, _ := sql.Open("mysql", "user:password@tcp(host:port)/dbname?multiStatements=true")
    driver, _ := mysql.WithInstance(db, &mysql.Config{})
    m, _ := migrate.NewWithDatabaseInstance(
        "file:///migrations",
        "mysql", 
        driver,
    )
    
    m.Steps(2)
}

Upgrading from v1

  1. Write down the current migration version from schema_migrations
  2. DROP TABLE schema_migrations
  3. Wrap your existing migrations in transactions (BEGIN/COMMIT) if you use multiple statements within one migration.
  4. Download and install the latest migrate version.
  5. Force the current migration version with migrate force <current_version>.

# Functions

instance must have `multiStatements` set to true.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author