-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service.user) config db & scaffold models (#12)
- Loading branch information
1 parent
3cde71c
commit 4d6be4c
Showing
22 changed files
with
6,170 additions
and
383 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,11 +1,11 @@ | ||
development: | ||
dialect: postgres | ||
datasource: host=localhost port=5433 dbname=certify_d user=postgres password=postgress sslmode=disable | ||
dir: migrations/postgres | ||
datasource: host=localhost port=5432 dbname=certify_d user=postgres sslmode=disable | ||
dir: postgres | ||
table: migrations | ||
|
||
production: | ||
dialect: postgres | ||
datasource: host=prodhost dbname=proddb user=${DB_USER} password=${DB_PASSWORD} sslmode=require | ||
dir: migrations/postgres | ||
dir: postgres | ||
table: migrations |
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
11 changes: 11 additions & 0 deletions
11
conf/db/migrations/postgres/20220701230935-user-service-schema.sql
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,11 @@ | ||
|
||
-- +migrate Up | ||
-- add user_service user and schema | ||
CREATE USER user_service WITH PASSWORD 'user_service'; | ||
CREATE SCHEMA user_service AUTHORIZATION user_service; | ||
alter user user_service set search_path to 'user_service'; | ||
|
||
-- +migrate Down | ||
-- remove user_service customer user and schema | ||
DROP SCHEMA IF EXISTS user_service; | ||
DROP USER IF EXISTS user_service; |
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,6 @@ | ||
|
||
-- +migrate Up | ||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
|
||
-- +migrate Down | ||
DROP EXTENSION IF EXISTS "uuid-ossp"; |
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
add-enum-types = true | ||
add-soft-deletes = true | ||
no-tests = true | ||
output = "pkg/models" | ||
wipe = true | ||
|
||
[psql] | ||
dbname = "certify_d" | ||
host = "localhost" | ||
port = 5432 | ||
user = "user_service" | ||
pass = "user_service" | ||
schema = "user_service" | ||
blacklist = ["migrations"] |
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,11 @@ | ||
development: | ||
dialect: postgres | ||
datasource: host=localhost port=5432 dbname=certify_d user=user_service password=user_service sslmode=disable | ||
dir: postgres | ||
table: migrations | ||
|
||
production: | ||
dialect: postgres | ||
datasource: host=prodhost dbname=proddb user=${DB_USER} password=${DB_PASSWORD} sslmode=require | ||
dir: postgres | ||
table: migrations |
62 changes: 62 additions & 0 deletions
62
service.user/db/migrations/postgres/20220714222311-init.sql
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,62 @@ | ||
-- +migrate Up | ||
-- Create tables and relationships | ||
|
||
CREATE TYPE "user_service"."permission_ref" AS ENUM ( | ||
'super_admin', | ||
'admin' | ||
); | ||
|
||
CREATE TABLE "user_service"."user" ( | ||
"id" uuid PRIMARY KEY NOT NULL DEFAULT (public.uuid_generate_v4()), | ||
"role_id" uuid NOT NULL, | ||
"created_at" timestamp DEFAULT 'now()', | ||
"updated_at" timestamp, | ||
"deleted_at" timestamp | ||
); | ||
|
||
CREATE TABLE "user_service"."role" ( | ||
"id" uuid PRIMARY KEY NOT NULL DEFAULT (public.uuid_generate_v4()), | ||
"slug" text UNIQUE NOT NULL, | ||
"created_at" timestamp DEFAULT 'now()', | ||
"updated_at" timestamp, | ||
"deleted_at" timestamp | ||
); | ||
|
||
CREATE TABLE "user_service"."role_permission" ( | ||
"id" uuid NOT NULL DEFAULT (public.uuid_generate_v4()), | ||
"role_id" uuid NOT NULL, | ||
"permission_id" uuid NOT NULL, | ||
"created_at" timestamp DEFAULT 'now()', | ||
"updated_at" timestamp, | ||
"deleted_at" timestamp, | ||
PRIMARY KEY ("id", "role_id", "permission_id") | ||
); | ||
|
||
CREATE TABLE "user_service"."permission" ( | ||
"id" uuid PRIMARY KEY NOT NULL DEFAULT (public.uuid_generate_v4()), | ||
"slug" user_service.permission_ref UNIQUE NOT NULL, | ||
"created_at" timestamp DEFAULT 'now()', | ||
"updated_at" timestamp, | ||
"deleted_at" timestamp | ||
); | ||
|
||
ALTER TABLE "user_service"."user" ADD FOREIGN KEY ("role_id") REFERENCES "user_service"."role" ("id"); | ||
|
||
ALTER TABLE "user_service"."role_permission" ADD FOREIGN KEY ("role_id") REFERENCES "user_service"."role" ("id"); | ||
|
||
ALTER TABLE "user_service"."role_permission" ADD FOREIGN KEY ("permission_id") REFERENCES "user_service"."permission" ("id"); | ||
|
||
-- Seed values | ||
INSERT INTO "user_service"."role" ("slug") VALUES('customer'); | ||
|
||
-- +migrate Down | ||
-- Drop table & relationships | ||
DROP TABLE "user_service"."role_permission" CASCADE; | ||
|
||
DROP TABLE "user_service"."permission" CASCADE; | ||
|
||
DROP TABLE "user_service"."role" CASCADE; | ||
|
||
DROP TABLE "user_service"."user" CASCADE; | ||
|
||
DROP TYPE "user_service"."permission_ref" CASCADE; |
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
Oops, something went wrong.