mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat: add postgres support (#215)
* feat: add postgres support and refactor * feat: improve releases find * fix: autobrrctl create user
This commit is contained in:
parent
f6873e932e
commit
3185832708
30 changed files with 1708 additions and 831 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue