From 21e06a0b6f64913287d1cdc857171ed2a03c512b Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Mon, 10 Jan 2022 11:07:18 +0530 Subject: [PATCH] Switch kratos from using mem to db --- README.md | 7 +++---- components/usermgmt/README.md | 8 +++++++- components/usermgmt/_kratos/kratos.yml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 46d0c9c..a2559df 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,11 @@ grant execute on function uuid_generate_v4() to admindbuser; *This will grant the necessary permission to the newly created user to run uuid_generate_v4()* -### Run migrations +### Run application migrations We use [`golang-migrate`](https://github.com/golang-migrate/migrate) to perform migrations. -### Install [`golang-migrate`](https://github.com/golang-migrate/migrate) +#### Install [`golang-migrate`](https://github.com/golang-migrate/migrate) ``` shell go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest @@ -35,7 +35,7 @@ go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@lat You can refer to the [guide](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate) for full details. -### Run migrations +#### Run migrations Example for `admindb`: @@ -45,4 +45,3 @@ migrate -path ./persistence/migrations/admindb -database "$POSTGRESQL_URL" up ``` See [cli-usage](https://github.com/golang-migrate/migrate#cli-usage) for more info. - diff --git a/components/usermgmt/README.md b/components/usermgmt/README.md index 1b09a84..73b5c39 100644 --- a/components/usermgmt/README.md +++ b/components/usermgmt/README.md @@ -6,6 +6,13 @@ All user/auth related requests go through here. ## Development +### Run kratos migrations + +``` shell +export DSN='postgres://admindbuser@localhost:5432/admindb?sslmode=disable' +kratos -c kratos.yaml migrate sql -e --yes +``` + ### Start kratos ``` shell @@ -19,4 +26,3 @@ kratos serve -c kratos.yml cd components/usermgmt/_kratos go run main.go ``` - diff --git a/components/usermgmt/_kratos/kratos.yml b/components/usermgmt/_kratos/kratos.yml index 72bc8de..2e5ce71 100644 --- a/components/usermgmt/_kratos/kratos.yml +++ b/components/usermgmt/_kratos/kratos.yml @@ -1,6 +1,6 @@ version: v0.7.1-alpha.1 -dsn: memory +dsn: postgres://admindbuser@localhost:5432/admindb?sslmode=disable serve: public: