feat: add postgres support (#215)

* feat: add postgres support and refactor

* feat: improve releases find

* fix: autobrrctl create user
This commit is contained in:
Ludvig Lundgren 2022-04-02 19:24:23 +02:00 committed by GitHub
parent f6873e932e
commit 3185832708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 1708 additions and 831 deletions

View file

@ -6,6 +6,7 @@ import (
"fmt"
"sync"
sq "github.com/Masterminds/squirrel"
"github.com/rs/zerolog/log"
"github.com/autobrr/autobrr/internal/domain"
@ -19,10 +20,15 @@ type DB struct {
Driver string
DSN string
squirrel sq.StatementBuilderType
}
func NewDB(cfg domain.Config) (*DB, error) {
db := &DB{}
db := &DB{
// set default placeholder for squirrel to support both sqlite and postgres
squirrel: sq.StatementBuilder.PlaceholderFormat(sq.Dollar),
}
db.ctx, db.cancel = context.WithCancel(context.Background())
switch cfg.DatabaseType {