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 and Gorm struct tags / DB columns and indexes definition #209

Open
frederikhors opened this issue Jan 5, 2019 · 4 comments
Open

Comments

@frederikhors
Copy link
Contributor

frederikhors commented Jan 5, 2019

Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).

I'm using authboss with Gorm and Postgresql.

I think we miss detailed instructions on how to set up DB columns and indexes.

Starting simply, what do you think about:

type User struct {
	ID int //but using Gorm you can use: gorm.Model (http://gorm.io/docs/models.html)

	// Non-authboss related field
	Name string

	// Auth
	Email    string `gorm:"type:varchar(100);unique_index"`
	Password string

        // from here I need help:

	// Confirm
	ConfirmSelector string
	ConfirmVerifier string
	Confirmed       bool

	// Lock
	AttemptCount int
	LastAttempt  time.Time
	Locked       time.Time

	// Recover
	RecoverSelector    string
	RecoverVerifier    string
	RecoverTokenExpiry time.Time

	// OAuth2
	OAuth2UID          string
	OAuth2Provider     string
	OAuth2AccessToken  string
	OAuth2RefreshToken string
	OAuth2Expiry       time.Time

	// 2fa
	TOTPSecretKey      string
	SMSPhoneNumber     string
	SMSSeedPhoneNumber string
	RecoveryCodes      string

	// Remember is in another table
}

And what about remember table?

@aarondl
Copy link
Member

aarondl commented Jan 6, 2019

Authboss makes no presumptions about your database. It only requires you to implement the storers as required and persist that data however you like. You may be saving it to a file serializing with JSON, or using google cloud storage. Therefore I don't think this kind of documentation belongs in Authboss or it's sample as we'd have to be committed to having all databases have some documentation which isn't feasible.

I think it's better to simply add documentation surrounding what a schema might look like (database agnostic) with the list of all the columns/tables and types involved.

I'm specifically (and unjustly and unfairly) completely against any Gorm related documentation as I'm the creator of https://github.com/volatiletech/sqlboiler and I don't want to proliferate gorm anymore than it already has been, it's not a good solution to databases in Go and it performs extremely poorly as well (see benchmarks at bottom of sqlboiler readme).

@ghost
Copy link

ghost commented Feb 15, 2019

sqlboiler is way better than GORM is so many ways IMHO.

@aarondl I wonder if its worth adding a formal drivers package, with sqlboiler as the default.
Maybe we can then use the golang teams go-cloud also.

https://github.com/google/go-cloud

https://github.com/google/go-cloud/tree/master/postgres

@aarondl
Copy link
Member

aarondl commented Feb 16, 2019

I'm not opposed to this. It was originally intended to go this way anyway.

@ghost
Copy link

ghost commented Feb 16, 2019

@aarondl
I hope it does go that way. +1 from me.

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