diff --git a/README.md b/README.md index 104cd6cd..234d8819 100644 --- a/README.md +++ b/README.md @@ -173,11 +173,9 @@ drop_foreign_key("table_name", "fk_name", {"if_exists": true}) ## Raw SQL ``` javascript -raw("select * from users;") +sql("select * from users;") ``` -*All calls to `raw` must end with a `;`!* - ## Execute an External Command Sometimes during a migration you need to shell out to an external command. diff --git a/bubbler.go b/bubbler.go index 9084fee9..13dea2f3 100644 --- a/bubbler.go +++ b/bubbler.go @@ -35,6 +35,7 @@ func (b *Bubbler) Bubble(s string) (string, error) { "drop_column": f.DropColumn, "rename_column": f.RenameColumn, "raw": f.RawSql, + "sql": f.RawSql, "add_index": f.AddIndex, "drop_index": f.DropIndex, "rename_index": f.RenameIndex, diff --git a/fizz.go b/fizz.go index 216ca504..ee055b1c 100644 --- a/fizz.go +++ b/fizz.go @@ -3,7 +3,6 @@ package fizz import ( "io" "io/ioutil" - "log" "os" "os/exec" "strings" @@ -19,7 +18,7 @@ type fizzer struct { func (f fizzer) add(s string, err error) error { if err != nil { - panic(err.Error()) + return errors.WithStack(err) } f.Bubbler.data = append(f.Bubbler.data, s) return nil @@ -43,7 +42,7 @@ func (f fizzer) Exec(out io.Writer) func(string) error { func AFile(f *os.File, t Translator) (string, error) { b, err := ioutil.ReadAll(f) if err != nil { - log.Fatal(err) + return "", errors.WithStack(err) } return AString(string(b), t) } diff --git a/raw_sql.go b/raw_sql.go index 3f3b67b2..053a4ac2 100644 --- a/raw_sql.go +++ b/raw_sql.go @@ -1,6 +1,8 @@ package fizz -import "strings" +import ( + "strings" +) func (f fizzer) RawSql(sql string) { if !strings.HasSuffix(sql, ";") {