Skip to content

Commit afabcd0

Browse files
Merge pull request #23 from GauravJangra9988/db-initializtion-fix
Fix (Issue: #15): Added flag to optionally initialize db
2 parents 3277cd8 + 51fcadf commit afabcd0

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export MAILER_PASSWORD=<mailer_password>
2222
export FRONTEND_URL=<frontend_url>
2323
export HTTP_PORT=5000
2424
export GRPC_PORT=5001
25+
export INIT_DB=true
26+
export ENV=DEVELOPMENT
2527
```
2628
3. Install the protobuf-grpc compiler.
2729
```sh

db/init.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import (
1010
func InitDb(ctx context.Context) error {
1111

1212
logger := util.SharedLogger
13+
14+
if os.Getenv("INIT_DB") != "true" {
15+
logger.Info("initDb: skipping database initialization")
16+
return nil
17+
}
18+
1319
conn, err := connection.PoolConn(ctx)
1420
if err != nil {
1521
logger.Error("initDb: failed to get pool connection", err)

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ services:
1717
HTTP_PORT: 5000
1818
GRPC_PORT: 5001
1919
ENV: DEVELOPMENT
20+
INIT_DB: true

0 commit comments

Comments
 (0)