This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
276 changed files
with
1,653 additions
and
5,924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.