Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

down and related commands fail [redshift] #146

Closed
eeshugerman opened this issue Mar 1, 2019 · 8 comments
Closed

down and related commands fail [redshift] #146

eeshugerman opened this issue Mar 1, 2019 · 8 comments

Comments

@eeshugerman
Copy link

eeshugerman commented Mar 1, 2019

down, down-to, and redo fail like so: FAIL pq: operator does not exist: bigint =?, quitting migration

The source of this error is line 175 194 of migration_sql.go: tx.Exec(GetDialect().deleteVersionSQL(), v)

Apparently the ? isn't getting replaced by the version number.

Perhaps this has something to do with it?

I'm curious if Postgres users are running into this too.

@VojtechVitek
Copy link
Collaborator

Hi, thanks for raising this issue.

Postgres works like a charm!

Anyone able to debug this further? I have no idea why Redshift would fail on a syntax that's part of this codebase since the beginning:

goose/dialect.go

Lines 61 to 76 in 7a98874

func (pg PostgresDialect) insertVersionSQL() string {
return fmt.Sprintf("INSERT INTO %s (version_id, is_applied) VALUES ($1, $2);", TableName())
}
func (pg PostgresDialect) dbVersionQuery(db *sql.DB) (*sql.Rows, error) {
rows, err := db.Query(fmt.Sprintf("SELECT version_id, is_applied from %s ORDER BY id DESC", TableName()))
if err != nil {
return nil, err
}
return rows, err
}
func (pg PostgresDialect) deleteVersionSQL() string {
return fmt.Sprintf("DELETE FROM %s WHERE version_id=$1;", TableName())
}

^ the insertVersionSQL() func is old; and the deleteVersionSQL() func is quite new

@eeshugerman
Copy link
Author

I've added a ticket for my team to look into this, hopefully we can get to the bottom of it. It was member of our team (who has since left) that added Redshift support originally, so it might be up to us to keep it alive!

@eeshugerman
Copy link
Author

the insertVersionSQL() func is old; and the deleteVersionSQL() func is quite new

It's deleteVersionSQL that is breaking so I suppose that makes sense.

Also I should mention that this bug is not brand new. We've had this issue for a little while now, I'd estimate a month or two.

@VojtechVitek
Copy link
Collaborator

Sounds good. Thanks @eeshugerman!

@VojtechVitek
Copy link
Collaborator

VojtechVitek commented Mar 6, 2019

@eeshugerman hey, FYI, I accidentally figured out the bug when working on unrelated branch. Fixed in #156.

@VojtechVitek
Copy link
Collaborator

@eeshugerman Please, report back if the fix is OK. Going to release v2.7.0-rc2.

@eeshugerman
Copy link
Author

eeshugerman commented Mar 6, 2019

@VojtechVitek Sweet! Unfortunately I'm a golang noob. How do I build the new version? I did git pull on the master branch and then sudo make dist but I get

GOOS=darwin  GOARCH=amd64 go build -o ./bin/goose-darwin64       ./cmd/goose
# _/go/src/github.com/pressly/goose/cmd/goose
cmd/goose/main.go:25:15: undefined: goose.VERSION
cmd/goose/main.go:58:13: undefined: goose.OpenDBWithDriver
Makefile:3: recipe for target 'dist' failed
make: *** [dist] Error 2

@eeshugerman
Copy link
Author

eeshugerman commented Mar 7, 2019

@VojtechVitek I pulled the new changes today and the build worked, and yep the bug is fixed. Thanks for taking care of this so quickly!

edit: hmm looks like there are no new commits to master since Tuesday, so not sure what went wrong with my git pull the first time. Anyway, thanks again!

skinner added a commit to skinner/goose that referenced this issue Sep 14, 2021
Copy fix from pressly#146.  At some point (probably after we upgrade our go version) we should update our goose fork from upstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants