gobuffalo / buffalo

Rapid Web Development w/ Go
http://gobuffalo.io
MIT License
8.08k stars 579 forks source link

"bin/myapp migrate" fails but "buffalo db migrate" works - could not fizz the migration #1123

Closed drnic closed 6 years ago

drnic commented 6 years ago

Steps to Reproduce the Problem

Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the curl command you used, that sort of thing.

  1. Using the app developed following https://gobuffalo.io/en/docs/generators tutorial
  2. buffalo create -a && buffalo db migrate works as expected and the app runs fine
  3. buffalo drop -a && buffalo build && bin/buffalo_testapp migrate fails

Expected Behavior

Migrations should have run.

Actual Behavior

$ bin/buffalo_testapp migrate
DEBU[2018-06-21T16:54:55+10:00] select count(*) as row_count from (SELECT schema_migration.* FROM schema_migration AS schema_migration WHERE version = $1) a $1="20180621060932"

0.0430 seconds
2018/06/21 16:54:55 Failed to run migrations: error processing 20180621060932_create_users.up.fizz: could not fizz the migration 20180621060932_create_users.up.fizz: parse error: function run error: function wants argument type fizz.Options but received type map[string]interface {}

Info

``` ### Buffalo Version v0.12.0 ### App Information Pwd=/Users/drnic/Projects/gopath/src/buffalo_testapp Root=/Users/drnic/Projects/gopath/src/buffalo_testapp GoPath=/Users/drnic/Projects/gopath Name=buffalo_testapp Bin=bin/buffalo_testapp PackagePkg=buffalo_testapp ActionsPkg=buffalo_testapp/actions ModelsPkg=buffalo_testapp/models GriftsPkg=buffalo_testapp/grifts VCS=git WithPop=true WithSQLite=false WithDep=true WithWebpack=true WithYarn=true WithDocker=true WithGrifts=true ### Go Version go version go1.10.3 darwin/amd64 ### Go Env GOARCH="amd64" GOBIN="" GOCACHE="/Users/drnic/Library/Caches/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/drnic/Projects/gopath" GORACE="" GOROOT="/usr/local/Cellar/go/1.10.3/libexec" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.10.3/libexec/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" CGO_ENABLED="1" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wd/xnncwqp96rj0v1y2nms64mq80000gn/T/go-build344015229=/tmp/go-build -gno-record-gcc-switches -fno-common" ### Node Version v10.4.1 ### NPM Version 6.1.0 ### Yarn Version 1.7.0 ### PostgreSQL Version pg_ctl (PostgreSQL) 10.4 ### SQLite Version 3.19.3 2017-06-27 16:48:08 2b0954060fe10d6de6d479287dd88890f1bef6cc1beca11bc6cdb79f72e2377b ### Dep Version dep: version : devel build date : git hash : go version : go1.9.2 go compiler : gc platform : darwin/amd64 ### Dep Status PROJECT CONSTRAINT VERSION REVISION LATEST PKGS USED dmitri.shuralyov.com/text/kebabcase branch master branch master 40e40b4 40e40b4 1 github.com/BurntSushi/toml v0.3.0 v0.3.0 b26d9c3 b26d9c3 1 github.com/ajg/form v1.5 v1.5 cc29540 cc29540 1 github.com/cockroachdb/cockroach-go branch master branch master 59c0560 59c0560 1 github.com/davecgh/go-spew v1.1.0 v1.1.0 346938d 346938d 1 github.com/dustin/go-humanize branch master branch master 02af396 02af396 1 github.com/fatih/color v1.7.0 v1.7.0 5b77d2a 5b77d2a 1 github.com/fatih/structs v1.0 v1.0 a720dfa a720dfa 1 github.com/fsnotify/fsnotify v1.4.7 v1.4.7 c282820 c282820 1 github.com/go-sql-driver/mysql v1.4.0 v1.4.0 d523deb d523deb 1 github.com/gobuffalo/buffalo v0.12.0 v0.12.0 7dd791f 7dd791f 8 github.com/gobuffalo/envy v1.6.3 v1.6.3 2d0f467 2d0f467 1 github.com/gobuffalo/makr v1.1.0 v1.1.0 2f752af 2f752af 1 github.com/gobuffalo/packr v1.11.1 v1.11.1 bd47f28 bd47f28 1 github.com/gobuffalo/plush v3.7.7 v3.7.7 2ec029f 2ec029f 5 github.com/gobuffalo/pop v4.5.10 v4.5.10 fb309e2 fb309e2 6 github.com/gobuffalo/suite v2.1.1 v2.1.1 e2e0134 e2e0134 2 github.com/gobuffalo/tags v2.0.6 v2.0.6 1b65be1 1b65be1 3 github.com/gobuffalo/uuid v2.0.0 v2.0.0 3a9fb6c 3a9fb6c 1 github.com/gobuffalo/validate v2.0.0 v2.0.0 42d8db6 42d8db6 2 github.com/gobuffalo/x branch master branch master 11ca13c 11ca13c 1 github.com/gorilla/context v1.1.1 v1.1.1 08b5f42 08b5f42 1 github.com/gorilla/mux v1.6.2 v1.6.2 e3702be e3702be 1 github.com/gorilla/securecookie v1.1.1 v1.1.1 e59506c e59506c 1 github.com/gorilla/sessions v1.1.1 v1.1.1 03b6f63 03b6f63 1 github.com/jmoiron/sqlx branch master branch master 0dae4fe 0dae4fe 2 github.com/joho/godotenv v1.2.0 v1.2.0 a79fa1e a79fa1e 1 github.com/lib/pq branch master branch master 90697d6 90697d6 2 github.com/markbates/going v1.0.0 v1.0.0 0576708 0576708 3 github.com/markbates/grift v1.0.0 v1.0.0 76f9361 76f9361 1 github.com/markbates/hmax v1.0.0 v1.0.0 800e180 800e180 1 github.com/markbates/inflect v1.0.0 v1.0.0 dd7de90 dd7de90 1 github.com/markbates/refresh v1.4.0 v1.4.0 fab0ab1 fab0ab1 2 github.com/markbates/sigtx v1.0.0 v1.0.0 daa2e5f daa2e5f 1 github.com/markbates/willie v1.0.0 v1.0.0 6793494 6793494 1 github.com/mattn/anko v0.0.5 v0.0.5 9bd0532 9bd0532 5 github.com/mattn/go-colorable v0.0.9 v0.0.9 167de6b 167de6b 1 github.com/mattn/go-isatty v0.0.3 v0.0.3 0360b2a 0360b2a 1 github.com/mattn/go-sqlite3 v1.9.0 v1.9.0 25ecb14 25ecb14 1 github.com/microcosm-cc/bluemonday branch master branch master 995366f 995366f 1 github.com/mitchellh/go-homedir branch master branch master 3864e76 3864e76 1 github.com/monoculum/formam v3.0 v3.0 99ca9dc 99ca9dc 1 github.com/nicksnyder/go-i18n v1.10.0 v1.10.0 0dc1626 0dc1626 4 github.com/pelletier/go-toml v1.2.0 v1.2.0 c01d127 c01d127 1 github.com/pkg/errors v0.8.0 v0.8.0 645ef00 645ef00 1 github.com/pmezard/go-difflib v1.0.0 v1.0.0 792786c 792786c 1 github.com/russross/blackfriday branch master branch master 11635eb 11635eb 1 github.com/serenize/snaker branch master branch master a683aaf a683aaf 1 github.com/sergi/go-diff v1.0.0 v1.0.0 1744e29 1744e29 1 github.com/shurcooL/github_flavored_markdown branch master branch master 8913699 8913699 1 github.com/shurcooL/go branch master branch master 9e1955d 9e1955d 4 github.com/shurcooL/go-goon branch master branch master 37c2f52 37c2f52 1 github.com/shurcooL/graphql branch master branch master 62c9ce0 62c9ce0 1 github.com/shurcooL/highlight_diff branch master branch master 09bb405 09bb405 1 github.com/shurcooL/highlight_go branch master branch master 78fb10f 78fb10f 1 github.com/shurcooL/octicon branch master branch master c42b0e3 c42b0e3 1 github.com/shurcooL/sanitized_anchor_name branch master branch master 86672fc 86672fc 1 github.com/sirupsen/logrus v1.0.5 v1.0.5 c155da1 c155da1 1 github.com/sourcegraph/annotate branch master branch master f4cad6c f4cad6c 1 github.com/sourcegraph/syntaxhighlight branch master branch master bd320f5 bd320f5 1 github.com/stretchr/testify v1.2.2 v1.2.2 f35b8ab f35b8ab 3 golang.org/x/crypto branch master branch master 7f39a6f 7f39a6f 3 golang.org/x/net branch master branch master db08ff0 db08ff0 3 golang.org/x/sync branch master branch master 1d60e46 1d60e46 1 golang.org/x/sys branch master branch master ad87a3a ad87a3a 2 google.golang.org/appengine v1.1.0 v1.1.0 b1f2635 b1f2635 1 gopkg.in/yaml.v2 v2.2.1 v2.2.1 5420a8b 5420a8b 1 ```
markbates commented 6 years ago

There is a patch release going out this evening to fix this issue.

https://github.com/gobuffalo/buffalo/pull/1125

drnic commented 6 years ago

In the https://github.com/gobuffalo/gothrecipe project I get a different error:

buffalo db migrate works as expected:

$ buffalo db migrate
v4.5.10

> create_users
> create_widgets

0.1183 seconds
dumped schema for gothrecipe_development

But bin/gothrecipe migrate fails:

$ buffalo db drop -a
$ buffalo db create -a
$ buffalo build
$ bin/gothrecipe migrate
panic: sql: Register called twice for driver postgres

goroutine 1 [running]:
database/sql.Register(0x1a801bb, 0x8, 0x1c2cf00, 0x2118128)
    /usr/local/Cellar/go/1.10.3/libexec/src/database/sql/sql.go:50 +0x1a4
github.com/gobuffalo/gothrecipe/vendor/github.com/lib/pq.init.0()
    /Users/drnic/Projects/gopath/src/github.com/gobuffalo/gothrecipe/vendor/github.com/lib/pq/conn.go:49 +0x5c
drnic commented 6 years ago

@markbates ah awesome

markbates commented 6 years ago

Nope, sorry, that’s another issue that has been fixed. I’m on my phone and can’t find the details though. Sorry.

markbates commented 6 years ago

Nope, sorry again. You at piggy backing on another issue and I got confused. The patch tonight will fix the sub issue. Please use new ones on the future. I’m easily confused. :)

drnic commented 6 years ago

I'll move it to a new issue

markbates commented 6 years ago

Fixed with #1126

drnic commented 6 years ago

I upgraded to v0.12.1 and this problem still exists.

$ buffalo update
$ git diff
+++ b/Gopkg.lock
@@ -64,8 +64,8 @@
 [[projects]]
   name = "github.com/gobuffalo/buffalo"
   packages = [".","binding","middleware","middleware/csrf","middleware/i18n","render","servers","worker"]
-  revision = "7dd791f448a9ff897c3f63e2fc2008b184098c02"
-  version = "v0.12.0"
+  revision = "9182ee5fe475fd22261e35b0eec09552a7860514"
+  version = "v0.12.1"

$ buffalo db drop -a
$ buffalo db create -a
$ buffalo build
$ bin/* migrate
DEBU[2018-06-22T11:57:18+10:00] CREATE TABLE "schema_migration" (
"version" VARCHAR (255) NOT NULL
);
CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version);
DEBU[2018-06-22T11:57:18+10:00] select count(*) as row_count from (SELECT schema_migration.* FROM schema_migration AS schema_migration WHERE version = $1) a $1="20180621060932"

0.0703 seconds
2018/06/22 11:57:18 Failed to run migrations: error processing 20180621060932_create_users.up.fizz: could not fizz the migration 20180621060932_create_users.up.fizz: parse error: function run error: function wants argument type fizz.Options but received type map[string]interface {}

Update: realised I hadn't run go get -u -v github.com/gobuffalo/buffalo before buffalo build. Trying that now.

Confirmed the issue persists after updating buffalo CLI project; and running buffalo update.

drnic commented 6 years ago

On the plus side? The #1124 issue is resolved; but now for gothrecipe project I get this #1123 issue as well:

$ bin/gothrecipe migrate
DEBU[2018-06-22T12:03:00+10:00] CREATE TABLE "schema_migration" (
"version" VARCHAR (255) NOT NULL
);
CREATE UNIQUE INDEX "schema_migration_version_idx" ON "schema_migration" (version);
DEBU[2018-06-22T12:03:00+10:00] select count(*) as row_count from (SELECT schema_migration.* FROM schema_migration AS schema_migration WHERE version = $1) a $1="20170629182437"

0.2023 seconds
2018/06/22 12:03:00 Failed to run migrations: error processing 20170629182437_create_users.up.fizz: could not fizz the migration 20170629182437_create_users.up.fizz: parse error: function run error: function wants argument type fizz.Options but received type map[string]interface {}
drnic commented 6 years ago

@markbates you ok to re-open this issue? Or want me to recreate it? I'm blocked from deploying to prod using a binary. I'm not sure of the nature of the problem to help debugging. Tips?

markbates commented 6 years ago

@drnic please recreate; I've completely lost track in this one. :)