fix postgresql issues
This commit is contained in:
@@ -87,6 +87,6 @@ func (s MongoDBStorage) SubscribeIncentive(incentive_subscription IncentiveSubsc
|
||||
return nil
|
||||
}
|
||||
|
||||
func (psql MongoDBStorage) Migrate() error {
|
||||
func (s MongoDBStorage) Migrate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ func NewPostgresqlStorage(cfg *viper.Viper) (PostgresqlStorage, error) {
|
||||
func (s PostgresqlStorage) GetUserSubscriptions(userid string) ([]IncentiveSubscription, error) {
|
||||
|
||||
req := fmt.Sprintf(`SELECT id, incentive_id, user_id, identity_verification_ids, data, declined, subscription_datetime
|
||||
FROM %s
|
||||
WHERE user_id=$1`, s.Tables["incentive_subscriptions"])
|
||||
FROM %s WHERE user_id = $1`, s.Tables["incentive_subscriptions"])
|
||||
rows, err := s.DbConnection.Query(req, userid)
|
||||
if err != nil {
|
||||
log.Error().Str("request", req).Err(err).Msg("GetUserSubscriptions query error")
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -15,6 +15,7 @@ table "incentive_subscriptions" {
|
||||
column "identity_verification_ids" {
|
||||
null = true
|
||||
type = sql("text[]")
|
||||
default = sql("array[]::text[]")
|
||||
}
|
||||
column "data" {
|
||||
null = false
|
||||
@@ -27,6 +28,7 @@ table "incentive_subscriptions" {
|
||||
column "subscription_datetime" {
|
||||
null = true
|
||||
type = timestamptz
|
||||
default = sql("now()")
|
||||
}
|
||||
primary_key {
|
||||
columns = [column.id]
|
||||
|
||||
@@ -22,6 +22,9 @@ func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
case "mongodb":
|
||||
s, err := NewMongoDBStorage(cfg)
|
||||
return s, err
|
||||
case "psql":
|
||||
s, err := NewPostgresqlStorage(cfg)
|
||||
return s, err
|
||||
default:
|
||||
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user