skip_interstitial_grants sql structure (#704)

This commit is contained in:
Michael Quigley 2024-07-24 11:16:36 -04:00
parent 2755422a29
commit 275666c2b2
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,18 @@
package store
import (
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)
func (str *Store) IsAccountGrantedSkipInterstitial(acctId int, trx *sqlx.Tx) (bool, error) {
stmt, err := trx.Prepare("select count(0) from skip_interstitial_grants where account_id = $1")
if err != nil {
return false, errors.Wrap(err, "error preparing skip_interstitial_grants select statement")
}
var count int
if err := stmt.QueryRow(acctId).Scan(&count); err != nil {
return false, errors.Wrap(err, "error querying skip_interstitial_grants count")
}
return count > 0, nil
}

View File

@ -0,0 +1,13 @@
-- +migrate Up
create table skip_interstitial_grants (
id serial primary key,
account_id integer references accounts (id) not null,
created_at timestamptz not null default(current_timestamp),
updated_at timestamptz not null default(current_timestamp),
deleted boolean not null default(false)
);
create index skip_interstitial_grants_id_idx on skip_interstitial_grants (account_id);

View File

@ -0,0 +1,13 @@
-- +migrate Up
create table skip_interstitial_grants (
id integer primary key,
account_id integer references accounts (id) not null,
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
deleted boolean not null default(false)
);
create index skip_interstitial_grants_id_idx on skip_interstitial_grants (account_id);