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

Postgres Support #176

Closed
mraerino opened this issue Jun 7, 2018 · 17 comments · May be fixed by #254
Closed

Postgres Support #176

mraerino opened this issue Jun 7, 2018 · 17 comments · May be fixed by #254
Labels

Comments

@mraerino
Copy link
Member

mraerino commented Jun 7, 2018

- Do you want to request a feature or report a bug?

Feature request

- What is the current behavior?

The docs state only mysql to be supported

- What is the expected behavior?

I'd really like to have postgres support.
What are the steps to get there?
pop should support postgres right?

@goodforever
Copy link

goodforever commented Sep 23, 2018

It's good if gotrue could support gorm like gocommerce . I like postgresql too.

@mraerino
Copy link
Member Author

The underlying orm (from gobuffalo) actually supports postgres and I actually got it working by converting the initial MySQL setup to postgres format

@goodforever
Copy link

@mraerino Can you share your codes with me ?

@mraerino
Copy link
Member Author

@goodforever here is the postgres setup based on the current migrations: https://gist.github.com/mraerino/d6932e2c01c79fa453d705f5ae93e641

This is being used in a docker setup with a db user called gotrue

Please note: Any further migrations will not be covered and could lead to problems.

@goodforever
Copy link

@mraerino I don't start gotrue now ,so I have no data dump problem , I hope to modify gotrue to support postgresql ,then use it. Do you have modified gotrue codes for pg support ?

@rybit
Copy link
Member

rybit commented Sep 25, 2018

So, I remember there was a reason to rip out gorm, but for the life of me I can't remember what it was. We would happily consider a PR to add gorm -- or other ORM -- but I don't think at netlify will be adding it anytime soon. I def won't stop the community though :)

@goodforever
Copy link

I see #47 ,It can support postgres, but there are no these code from git clone .

@mraerino
Copy link
Member Author

mraerino commented Sep 26, 2018

@goodforever there are no code changes needed to support postgres. it is already possible.

Try this configuration:

DATABASE_URL=postgres://user:password@host/db?sslmode=disable
GOTRUE_DB_DRIVER=postgres

The dump I linked to before has to be applied once to the database before launching gotrue.

@goodforever
Copy link

goodforever commented Sep 26, 2018

@mraerino What driver package is it for this config ? I use github.com/jinzhu/gorm/dialects/postgres ,When ./gotrue migrate, I can migrate only one table "schema_migration" .
I got errors
FATA[2018-09-26T21:11:14.417997032+08:00] pq: syntax error at or near "`"
github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop.(*Connection).timeFunc
/Users/work/space/go/src/github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop/connection.go:184
github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop.(*Query).Exec
/Users/work/space/go/src/github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop/executors.go:19
github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop.(*FileMigrator).findMigrations.func1.1
/Users//work/space/go/src/github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop/file_migrator.go:71
github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop.Migration.Run
/Users/work/space/go/src/github.com/netlify/gotrue/vendor/github.com/gobuffalo/pop/migration_info.go:27
........ etc.

@mraerino
Copy link
Member Author

@goodforever my advice was to not apply any migrations but instead build the database using my dump.
The migrations are mysql only and are not going to work.

@mraerino
Copy link
Member Author

What driver package is it for this config ? I use github.com/jinzhu/gorm/dialects/postgres

@goodforever and since this project does not use gorm, you will not have any luck using any gorm tooling.

@goodforever
Copy link

goodforever commented Sep 26, 2018

@mraerino I just want to support postgres , I read doc of github.com/gobuffalo/pop ,it can support postgres ,but how can I let it work ? if I don't migrate mysql sql ,is it correct in following config ?

in dial.go file
package storage

import (
"net/url"
"reflect"

//_ "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql"
//_ "github.com/go-sql-driver/mysql"
"github.com/gobuffalo/pop"
"github.com/gobuffalo/pop/columns"
//	_ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/netlify/gotrue/conf"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

)

in .env file

GOTRUE_DB_DRIVER=postgres
DATABASE_URL=postgres://gotrueuser:123456@localhost:30257/gotruedb?sslmode=disable

@stanislas-m
Copy link

Pop supports database suffixes in patch name: https://gobuffalo.io/en/docs/db/migrations#targeting-a-database

Supporting Postgres means renaming the existing migration files to add the suffix for MySQL, then create a Postgresql version of these patches.

@anuj509
Copy link

anuj509 commented Jul 14, 2019

@mraerino your dump works for me thanks. I am able to connect postgres db via postgres db url given above. only change I did is, I replaced schema to public and owner to postgres as default. However automigrate isn't working. I was able to automigrate in netlify's another repo of goecommerce.

@mraerino
Copy link
Member Author

@anuj509 See: #176 (comment)

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 7 days if no further activity occurs. Thanks!

@github-actions github-actions bot added the stale label Apr 24, 2021
@github-actions
Copy link

github-actions bot commented May 1, 2021

This issue was closed because it had no activity for over 1 year.

@github-actions github-actions bot closed this as completed May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants