Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from toggl/fix/change_namespace
Browse files Browse the repository at this point in the history
changed namespace to toggl/sql-migrate instead of togglhire
  • Loading branch information
nilsolofsson authored Sep 3, 2024
2 parents a33d891 + 9bc2314 commit 747612d
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 33 deletions.
35 changes: 17 additions & 18 deletions doc.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/togglhire/sql-migrate
module github.com/toggl/sql-migrate

go 1.16

Expand Down
4 changes: 2 additions & 2 deletions migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
"time"

"github.com/togglhire/sql-migrate/sqlparse"
"github.com/toggl/sql-migrate/sqlparse"
"gopkg.in/gorp.v1"
)

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"
"strings"

migrate "github.com/togglhire/sql-migrate"
migrate "github.com/toggl/sql-migrate"
)

type DownCommand struct {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_redo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

migrate "github.com/togglhire/sql-migrate"
migrate "github.com/toggl/sql-migrate"
)

type RedoCommand struct {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

migrate "github.com/togglhire/sql-migrate"
migrate "github.com/toggl/sql-migrate"
)

type SkipCommand struct {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/command_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"
"strings"

migrate "github.com/togglhire/sql-migrate"
migrate "github.com/toggl/sql-migrate"
)

type UpCommand struct {
Expand Down
2 changes: 1 addition & 1 deletion sql-migrate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion sql-migrate/godror.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build godror
// +build godror

// godror is another oracle driver
Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion sql-migrate/oracle.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions sqlparse/sqlparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 747612d

Please sign in to comment.