Skip to content

Commit

Permalink
Use golang migrate for database migrations
Browse files Browse the repository at this point in the history
Signed-off-by: William <[email protected]>
  • Loading branch information
kwesidev committed Sep 14, 2023
1 parent fd3c6e2 commit de03236
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include .env
all: clean buildserver

run:
Expand All @@ -12,5 +13,11 @@ test:
dockerbuild:
docker build -t authserver-app:latest .

migrateup:
migrate -source file://db/migrations -database 'postgres://$(PG_USER):$(PG_PASSWORD)@$(PG_HOST):$(PG_PORT)/$(PG_DB)?sslmode=disable' up

migratedown:
migrate -source file://db/migrations -database 'postgres://$(PG_USER):$(PG_PASSWORD)@$(PG_HOST):$(PG_PORT)/$(PG_DB)?sslmode=disable' down

clean:
rm -rf auth_server
9 changes: 0 additions & 9 deletions database/1_0_schema_version_table.sql

This file was deleted.

8 changes: 8 additions & 0 deletions db/migrations/000001_initial_schema.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BEGIN;
DROP TABLE IF EXISTS user_refresh_tokens;
DROP TABLE IF EXISTS reset_password_requests;
DROP TABLE IF EXISTS two_factor_requests;
DROP TABLE IF EXISTS user_roles;
DROP TABLE IF EXISTS roles;
DROP TABLE IF EXISTS users;
COMMIT;
File renamed without changes.

0 comments on commit de03236

Please sign in to comment.