-
Notifications
You must be signed in to change notification settings - Fork 209
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
Remember me, DB struct (table) hints. #218
Comments
There's not much in the way of advice for newbies, you have to understand databases and be able to create a schema that's adequate to store the data for authboss by yourself. That's the level of competency that's expected. The best thing we can do (as I talked about before) is document what pieces of data need to be stored and what they look like (string? int? max lengths?). |
Ok, but maybe we can also suggests a schema for postgres using SQLBoiler... I think FAQ with examples are the best way to learn and the best way to speed up using the right tools (SQLBoiler which I love). What do you think about? |
I'd be fine with a wiki page having this information. Could link to it from the readme. But I still think the most pertinent information for the README is what columns/types/tables you might need so that any database could be leveraged. |
I think for simple things a model like this is enough: type AuthToken struct {
Pid string `sql:"type:varchar(100)"`
Token string
CreatedAt time.Time `sql:"default:now()"`
} The Does it make sense to you, @aarondl? |
Not sure what exactly this struct is. SQL for postgres might look like this: create table auth_tokens (
pid text not null,
token text not null,
created_at timestamp not null,
constraint primary key (pid, token)
); |
I'm not using So I ended up with this code (generated from ORM) for Postgresql: DROP TABLE IF EXISTS "public"."auth_tokens";
CREATE TABLE "public"."auth_tokens" (
"pid" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"token" text COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamptz(6) NOT NULL DEFAULT now()
);
ALTER TABLE "public"."auth_tokens" ADD CONSTRAINT "auth_tokens_pkey" PRIMARY KEY ("pid", "token"); Do you think I'm ok with this? Do I really need a composite primary key for this table? |
Issue opened for the creation of a wiki page that summarizes the doubts and problems for newbies (#210).
In README.md is suggested the use of:
Any hint for indexes and columns?
Can we use something like:
What are the advice of an expert to a newbie in this case?
The text was updated successfully, but these errors were encountered: