limit_check_lock (#287)

This commit is contained in:
Michael Quigley 2024-05-15 14:31:26 -04:00
parent fecb8952c8
commit f0b0a959f0
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,17 @@
package store
import (
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)
func (str *Store) LimitCheckLock(acctId int, trx *sqlx.Tx) error {
rows, err := trx.Queryx("select * from limit_check_locks where account_id = $1 for update", acctId)
if err != nil {
return errors.Wrap(err, "error preparing limit_check_locks select statement")
}
if !rows.Next() {
return errors.Errorf("no limit_check_locks entry for account_id '%d'", acctId)
}
return nil
}

View File

@ -0,0 +1,7 @@
-- +migrate Up
create table limit_check_locks (
id serial primary key,
account_id integer not null references accounts (id),
updated_at timestamptz not null default(current_timestamp)
);

View File

@ -22,8 +22,9 @@ type Model struct {
}
type Config struct {
Path string `cf:"+secret"`
Type string
Path string `cf:"+secret"`
Type string
EnableLocking bool
}
type Store struct {