mirror of
https://github.com/pushbits/server.git
synced 2025-07-19 01:17:41 +02:00
feat: Add support for Postgres
There aren't many connection string examples for the postgres GORM driver, so a couple extra links are referenced. Most changes to go.mod and go.sum are automated changes as a result of running go mod tidy.
This commit is contained in:
parent
551a706358
commit
e2fbfbb28a
4 changed files with 39 additions and 63 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/pushbits/server/internal/model"
|
||||
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
@ -51,6 +52,8 @@ func Create(cm *credentials.Manager, dialect, connection string) (*Database, err
|
|||
db, err = gorm.Open(sqlite.Open(connection), &gorm.Config{})
|
||||
case "mysql":
|
||||
db, err = gorm.Open(mysql.Open(connection), &gorm.Config{})
|
||||
case "postgres":
|
||||
db, err = gorm.Open(postgres.Open(connection), &gorm.Config{})
|
||||
default:
|
||||
message := "Database dialect is not supported"
|
||||
return nil, errors.New(message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue