diff --git a/doc.go b/doc.go index 2446be0a..a5530770 100644 --- a/doc.go +++ b/doc.go @@ -1,24 +1,23 @@ /* - SQL Schema migration tool for Go. Key features: - * Usable as a CLI tool or as a library - * Supports SQLite, PostgreSQL, MySQL, MSSQL and Oracle databases (through gorp) - * Can embed migrations into your application - * Migrations are defined with SQL for full flexibility - * Atomic migrations - * Up/down migrations to allow rollback - * Supports multiple database types in one project + - Usable as a CLI tool or as a library + - Supports SQLite, PostgreSQL, MySQL, MSSQL and Oracle databases (through gorp) + - Can embed migrations into your application + - Migrations are defined with SQL for full flexibility + - Atomic migrations + - Up/down migrations to allow rollback + - Supports multiple database types in one project -Installation +# Installation To install the library and command line program, use the following: - go get -v github.com/togglhire/sql-migrate/... + go get -v github.com/toggl/sql-migrate/... -Command-line tool +# Command-line tool The main command is called sql-migrate. @@ -77,7 +76,7 @@ Use the status command to see the state of the applied migrations: | 2_record.sql | no | +---------------+-----------------------------------------+ -MySQL Caveat +# MySQL Caveat If you are using MySQL, you must append ?parseTime=true to the datasource configuration. For example: @@ -89,11 +88,11 @@ If you are using MySQL, you must append ?parseTime=true to the datasource config See https://github.com/go-sql-driver/mysql#parsetime for more information. -Library +# Library Import sql-migrate into your application: - import "github.com/togglhire/sql-migrate" + import "github.com/toggl/sql-migrate" Set up a source of migrations, this can be from memory, from a set of files or from bindata (more on that later): @@ -137,7 +136,7 @@ Note that n can be greater than 0 even if there is an error: any migration that The full set of capabilities can be found in the API docs below. -Writing migrations +# Writing migrations Migrations are defined in SQL files, which contain a set of SQL statements. Special comments are used to distinguish up and down migrations. @@ -183,7 +182,7 @@ Normally each migration is run within a transaction in order to guarantee that i -- +migrate Down DROP INDEX people_unique_id_idx; -Embedding migrations with packr +# Embedding migrations with packr If you like your Go applications self-contained (that is: a single binary): use packr (https://github.com/gobuffalo/packr) to embed the migration files. @@ -202,7 +201,7 @@ If you already have a box and would like to use a subdirectory: Dir: "./migrations", } -Embedding migrations with bindata +# Embedding migrations with bindata As an alternative, but slightly less maintained, you can use bindata (https://github.com/shuLhan/go-bindata) to embed the migration files. @@ -226,7 +225,7 @@ Both Asset and AssetDir are functions provided by bindata. Then proceed as usual. -Extending +# Extending Adding a new migration source means implementing MigrationSource. diff --git a/go.mod b/go.mod index 423f4327..3473e948 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/togglhire/sql-migrate +module github.com/toggl/sql-migrate go 1.16 diff --git a/migrate.go b/migrate.go index dfafa8c5..69570546 100644 --- a/migrate.go +++ b/migrate.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/togglhire/sql-migrate/sqlparse" + "github.com/toggl/sql-migrate/sqlparse" "gopkg.in/gorp.v1" ) @@ -735,7 +735,7 @@ func (ms MigrationSet) getMigrationDbMap(db *sql.DB, dialect string) (*gorp.DbMa // When using the mysql driver, make sure that the parseTime option is // configured, otherwise it won't map time columns to time.Time. See - // https://github.com/togglhire/sql-migrate/issues/2 + // https://github.com/toggl/sql-migrate/issues/2 if dialect == "mysql" { var out *time.Time err := db.QueryRow("SELECT NOW()").Scan(&out) diff --git a/sql-migrate/command_common.go b/sql-migrate/command_common.go index 7985ca4d..7272eb76 100644 --- a/sql-migrate/command_common.go +++ b/sql-migrate/command_common.go @@ -3,7 +3,7 @@ package main import ( "fmt" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) func ApplyMigrations(dir migrate.MigrationDirection, dryrun bool, limit int) error { diff --git a/sql-migrate/command_down.go b/sql-migrate/command_down.go index baaac820..caeb6fe1 100644 --- a/sql-migrate/command_down.go +++ b/sql-migrate/command_down.go @@ -4,7 +4,7 @@ import ( "flag" "strings" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) type DownCommand struct { diff --git a/sql-migrate/command_redo.go b/sql-migrate/command_redo.go index a478006a..09700e39 100644 --- a/sql-migrate/command_redo.go +++ b/sql-migrate/command_redo.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) type RedoCommand struct { diff --git a/sql-migrate/command_skip.go b/sql-migrate/command_skip.go index 87594cc7..4b07de6d 100644 --- a/sql-migrate/command_skip.go +++ b/sql-migrate/command_skip.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) type SkipCommand struct { diff --git a/sql-migrate/command_status.go b/sql-migrate/command_status.go index f0ebf16b..e349ed79 100644 --- a/sql-migrate/command_status.go +++ b/sql-migrate/command_status.go @@ -8,7 +8,7 @@ import ( "time" "github.com/olekukonko/tablewriter" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) type StatusCommand struct { diff --git a/sql-migrate/command_up.go b/sql-migrate/command_up.go index 0198bc2c..e34a12c2 100644 --- a/sql-migrate/command_up.go +++ b/sql-migrate/command_up.go @@ -4,7 +4,7 @@ import ( "flag" "strings" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) type UpCommand struct { diff --git a/sql-migrate/config.go b/sql-migrate/config.go index 925a910c..bc996d07 100644 --- a/sql-migrate/config.go +++ b/sql-migrate/config.go @@ -8,7 +8,7 @@ import ( "io/ioutil" "os" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" "gopkg.in/gorp.v1" "gopkg.in/yaml.v2" diff --git a/sql-migrate/godror.go b/sql-migrate/godror.go index 6707adb5..628788aa 100644 --- a/sql-migrate/godror.go +++ b/sql-migrate/godror.go @@ -1,3 +1,4 @@ +//go:build godror // +build godror // godror is another oracle driver @@ -10,7 +11,7 @@ package main import ( _ "github.com/godror/godror" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) func init() { diff --git a/sql-migrate/oracle.go b/sql-migrate/oracle.go index ffa22bc6..d91bb9ae 100644 --- a/sql-migrate/oracle.go +++ b/sql-migrate/oracle.go @@ -1,10 +1,11 @@ +//go:build oracle // +build oracle package main import ( _ "github.com/mattn/go-oci8" - migrate "github.com/togglhire/sql-migrate" + migrate "github.com/toggl/sql-migrate" ) func init() { diff --git a/sqlparse/sqlparse.go b/sqlparse/sqlparse.go index 82c06db5..f7e4bc02 100644 --- a/sqlparse/sqlparse.go +++ b/sqlparse/sqlparse.go @@ -35,11 +35,11 @@ var ( func errNoTerminator() error { if len(LineSeparator) == 0 { return errors.New(`ERROR: The last statement must be ended by a semicolon or '-- +migrate StatementEnd' marker. - See https://github.com/togglhire/sql-migrate for details.`) + See https://github.com/toggl/sql-migrate for details.`) } return errors.New(fmt.Sprintf(`ERROR: The last statement must be ended by a semicolon, a line whose contents are %q, or '-- +migrate StatementEnd' marker. - See https://github.com/togglhire/sql-migrate for details.`, LineSeparator)) + See https://github.com/toggl/sql-migrate for details.`, LineSeparator)) } // Checks the line to see if the line has a statement-ending semicolon @@ -221,7 +221,7 @@ func ParseMigration(r io.ReadSeeker) (*ParsedMigration, error) { if currentDirection == directionNone { return nil, errors.New(`ERROR: no Up/Down annotations found, so no statements were executed. - See https://github.com/togglhire/sql-migrate for details.`) + See https://github.com/toggl/sql-migrate for details.`) } // allow comment without sql instruction. Example: