Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Merge user & profile tables
Browse files Browse the repository at this point in the history
ref #1477
ref #1497
  • Loading branch information
louischan-oursky committed Jun 15, 2020
2 parents 789cde9 + 6e66e37 commit 6fbb8d8
Show file tree
Hide file tree
Showing 276 changed files with 1,653 additions and 5,924 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ vendor:
go install github.com/golang/mock/mockgen
go install github.com/google/wire/cmd/wire
go install github.com/skygeario/openapi3-gen/cmd/openapi3-gen
$(MAKE) -C migrate build

.PHONY: generate
generate:
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
# AuthGear

Work in progress

## Database setup

1. Setup dependencies:
```sh
make vendor
```
2. Create a schema:
```sql
CREATE SCHEMA app;
```
3. Setup environment variables (in `.env`):
```
DATABASE_URL=postgres://[email protected]:5432/postgres?sslmode=disable
DATABASE_SCHEMA=app
```
4. Apply database schema migrations:
```sh
./migrate/migrate up
```

To create new migration:
```sh
# ./migrate/migrate new <migration name>
./migrate/migrate new add user table
```
3 changes: 0 additions & 3 deletions cmd/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ type TemplateConfiguration struct {
@Tag User
User information
@Tag User Verification
Login IDs verification
@Tag Forgot Password
Password recovery process
@Tag Administration
Expand Down Expand Up @@ -135,7 +133,6 @@ func main() {
ReservedNameChecker: reservedNameChecker,
}

task.AttachVerifyCodeSendTask(asyncTaskExecutor, authDependency)
task.AttachPwHousekeeperTask(asyncTaskExecutor, authDependency)
task.AttachSendMessagesTask(asyncTaskExecutor, authDependency)

Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ require (
github.com/gorilla/csrf v1.6.2
github.com/gorilla/mux v1.7.4
github.com/h2non/gock v1.0.12
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/iawaknahc/gomessageformat v0.0.0-20200406084228-8abc010113fa
github.com/iawaknahc/originmatcher v0.0.0-20191203065535-c77f92cc0a75
github.com/jmoiron/sqlx v0.0.0-20170430194603-d9bd385d68c0
github.com/joho/godotenv v0.0.0-20150907010228-4ed13390c0ac
github.com/joho/godotenv v1.3.0
github.com/kelseyhightower/envconfig v1.3.0
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/lestrrat-go/jwx v0.9.0
github.com/lib/pq v1.2.0
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/mattn/go-sqlite3 v1.12.0 // indirect
github.com/mitchellh/gox v1.0.1
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20171102151520-eafdab6b0663
Expand All @@ -39,7 +41,7 @@ require (
github.com/skygeario/go-confusable-homoglyphs v0.0.0-20191212061114-e2b2a60df110
github.com/skygeario/openapi3-gen v0.0.0-20190808034633-90418c3d9171
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337
github.com/smartystreets/goconvey v1.6.4
github.com/tinylib/msgp v1.1.0
github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31 // indirect
github.com/ua-parser/uap-go v0.0.0-20190826212731-daf92ba38329
Expand Down
14 changes: 10 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ github.com/h2non/gock v1.0.12 h1:e1lLoiLdVdzJoqqCRtm1tbqCEDWG9Xei/1mzmav+GAs=
github.com/h2non/gock v1.0.12/go.mod h1:CZMcB0Lg5IWnr9bF79pPMg9WeV6WumxQiUJ1UvdO1iE=
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iawaknahc/gomessageformat v0.0.0-20200406084228-8abc010113fa h1:R2zZa1jkoNunaUgy2NCzwh61kj6PMAYS5/DA8M+Tmss=
github.com/iawaknahc/gomessageformat v0.0.0-20200406084228-8abc010113fa/go.mod h1:N6C14Rpg3pJZ9zDMbmF/zPu8LJDsmVzMAD3bc+bregI=
Expand All @@ -81,8 +83,8 @@ github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/
github.com/iris-contrib/httpexpect v0.0.0-20180314041918-ebe99fcebbce/go.mod h1:VER17o2JZqquOx41avolD/wMGQSFEFBKWmhag9/RQRY=
github.com/jmoiron/sqlx v0.0.0-20170430194603-d9bd385d68c0 h1:oZ1oQfWp4h9VX9Fmorc9DrmbHBwiw+mXphFDTVNp1vI=
github.com/jmoiron/sqlx v0.0.0-20170430194603-d9bd385d68c0/go.mod h1:IiEW3SEiiErVyFdH8NTuWjSifiEQKUoyK3LNqr2kCHU=
github.com/joho/godotenv v0.0.0-20150907010228-4ed13390c0ac h1:wF2VgtpbaLqhBHV9FxVWzgzgv8VcCjZ66Bl/+F6cpT0=
github.com/joho/godotenv v0.0.0-20150907010228-4ed13390c0ac/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand All @@ -99,6 +101,8 @@ github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand All @@ -118,8 +122,8 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-sqlite3 v1.11.0 h1:LDdKkqtYlom37fkvqs8rMPFKAMe8+SgjbwZ6ex1/A/Q=
github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.12.0 h1:u/x3mp++qUxvYfulZ4HKOvVO0JWhk7HtE8lWhbGz/Do=
github.com/mattn/go-sqlite3 v1.12.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
Expand Down Expand Up @@ -171,6 +175,8 @@ github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsR
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8=
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down
1 change: 1 addition & 0 deletions migrate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
migrate
75 changes: 3 additions & 72 deletions migrate/Makefile
Original file line number Diff line number Diff line change
@@ -1,72 +1,3 @@
SHELL := /bin/bash

SCHEMA ?= app_config

ifeq (1,$(WITH_CONTROLLER))
MIGRATION_ARG ?= -migration=core -migration=auth -migration=controller
else
# Sometimes only auth migration is added.
# The program complains if we run `up 1`.
#
# Intentionally not quoted
MIGRATION_ARG ?= -migration=core -migration=auth
endif

ifeq (1,$(DRY_RUN))
DRY_RUN_ARG := -dry-run
endif

AUTH_SOURCE ?= $(realpath ../migrations/auth)
CORE_SOURCE ?= $(realpath ../migrations/core)
CONTROLLER_SOURCE ?= $(realpath ../migrations/controller)

MIGRATE_CMD ?= version

ifneq (,$(APP_FILTER_KEY))
APP_FILTER_KEY_ARG := -app-filter-key=$(APP_FILTER_KEY)
endif

ifneq (,$(APP_FILTER_VALUE))
APP_FILTER_VALUE_ARG := -app-filter-value=$(APP_FILTER_VALUE)
endif

ifneq (,$(CONFIG_DATABASE))
CONFIG_DATABASE_ARG := -config-database=$(CONFIG_DATABASE)
endif

ifneq (,$(HOSTNAME_OVERRIDE))
HOSTNAME_OVERRIDE_ARG := -hostname-override=$(HOSTNAME_OVERRIDE)
endif

ifneq (,$(DATABASE_URL))
DATABASE_URL_ARG := -database=$(DATABASE_URL)
endif

.PHONY: migrate
migrate:
go run cmd/migrate/main.go \
-add-migration-src=auth,$(AUTH_SOURCE) \
-add-migration-src=core,$(CORE_SOURCE) \
-add-migration-src=controller,$(CONTROLLER_SOURCE) \
-schema $(SCHEMA) \
$(MIGRATION_ARG) \
$(DRY_RUN_ARG) \
$(APP_FILTER_KEY_ARG) \
$(APP_FILTER_VALUE_ARG) \
$(CONFIG_DATABASE_ARG) \
$(DATABASE_URL_ARG) \
$(MIGRATE_CMD)

.PHONY: http
http:
go run cmd/migrate/main.go \
-add-migration-src=auth,$(AUTH_SOURCE) \
-add-migration-src=core,$(CORE_SOURCE) \
-http-server

.PHONY: add-version
add-version: MODULE ?= INVALID
add-version: MIGRATION_DIR ?= $(realpath ../migrations/$(MODULE))
add-version:
cp $(MIGRATION_DIR)/templates/template.down.sql $(MIGRATION_DIR)/$(shell date +%s)_${REVISION}.down.sql
cp $(MIGRATION_DIR)/templates/template.up.sql $(MIGRATION_DIR)/$(shell date +%s)_${REVISION}.up.sql
.PHONY: build
build:
go build -o migrate .
22 changes: 0 additions & 22 deletions migrate/cmd/migrate/Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions migrate/cmd/migrate/Makefile

This file was deleted.

Loading

0 comments on commit 6fbb8d8

Please sign in to comment.