Skip to content

Commit

Permalink
Initialize psql database
Browse files Browse the repository at this point in the history
  • Loading branch information
toddnni committed Sep 16, 2024
1 parent 59fe5d2 commit 7521405
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions go-k8s-app/internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ func initPostgresDB() (DB, error) {
}

log.Println("Connected to the database")

createTableQuery := `
CREATE TABLE IF NOT EXISTS messages (
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT NOT NULL
);`
_, err = db.Exec(createTableQuery)
if err != nil {
return nil, fmt.Errorf("could not create table: %w", err)
}
log.Println("Initialized postgre database")

return &postgresDB{}, nil
}

Expand Down

0 comments on commit 7521405

Please sign in to comment.