Skip to content

Commit

Permalink
Update user model, schema and tests according to the Superbase Auth r…
Browse files Browse the repository at this point in the history
…equirements
  • Loading branch information
yasuflatland-lf committed Aug 22, 2024
1 parent 709712d commit 8b586a4
Show file tree
Hide file tree
Showing 18 changed files with 541 additions and 228 deletions.
3 changes: 3 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# No double quote needed for the text. Database will fail.
PORT=1323
GO_ENV=dev
GQL_COMPLEXITY=10
PG_HOST=localhost
PG_USER=your_db_user
PG_PASSWORD=your_db_password
PG_DBNAME=your_db_name
PG_PORT=5432
PG_SSLMODE=disable
FL_JWT_SECRET=test
FL_BATCH_DEFAULT_AMOUNT=10
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ CREATE TABLE IF NOT EXISTS users
(
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
google_id TEXT UNIQUE,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_users_id ON users(id);
CREATE INDEX idx_users_name ON users(name);
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_users_google_id ON users(google_id);

CREATE TABLE IF NOT EXISTS cardgroups
(
Expand Down
3 changes: 2 additions & 1 deletion backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ require (
github.com/99designs/gqlgen v0.17.49
github.com/caarlos0/env/v11 v11.1.0
github.com/go-playground/validator/v10 v10.22.0
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.0
github.com/graph-gophers/dataloader/v7 v7.1.0
github.com/joho/godotenv v1.5.1
Expand Down Expand Up @@ -46,7 +48,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
Expand Down
2 changes: 2 additions & 0 deletions backend/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down
2 changes: 2 additions & 0 deletions backend/graph/db/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
type User struct {
ID int64 `gorm:"column:id;primaryKey" validate:"number"`
Name string `gorm:"column:name;not null" validate:"required,fl_name"`
Email string `gorm:"column:email;not null" validate:"required,email"`
GoogleID string `gorm:"column:google_id" validate:"-"`
Created time.Time `gorm:"column:created;autoCreateTime"`
Updated time.Time `gorm:"column:updated;autoCreateTime"`
CardGroups []Cardgroup `gorm:"many2many:cardgroup_users" validate:"-"`
Expand Down
158 changes: 157 additions & 1 deletion backend/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions backend/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b586a4

Please sign in to comment.