fix: oauth2 query

This commit is contained in:
Tine 2024-02-27 15:55:35 +01:00
parent 8c4fc83ca0
commit 7035afe008
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
3 changed files with 10 additions and 8 deletions

View file

@ -1,7 +1,8 @@
-- +migrate Up -- +migrate Up
CREATE TABLE oauth2_states ( CREATE TABLE oauth2_states (
state TEXT, state TEXT,
expiry DATETIME, expires_at DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (state) PRIMARY KEY (state)
); );
@ -33,7 +34,8 @@ CREATE TABLE worker_groups (
CREATE TABLE monitor_worker_groups ( CREATE TABLE monitor_worker_groups (
worker_group_slug TEXT, worker_group_slug TEXT,
monitor_slug TEXT, monitor_slug TEXT,
PRIMARY KEY (worker_group_slug,monitor_slug), PRIMARY KEY (worker_group_slug,monitor_slug),
CONSTRAINT fk_monitor_worker_groups_worker_group FOREIGN KEY (worker_group_slug) REFERENCES worker_groups(slug), CONSTRAINT fk_monitor_worker_groups_worker_group FOREIGN KEY (worker_group_slug) REFERENCES worker_groups(slug),
CONSTRAINT fk_monitor_worker_groups_monitor FOREIGN KEY (monitor_slug) REFERENCES monitors(slug) CONSTRAINT fk_monitor_worker_groups_monitor FOREIGN KEY (monitor_slug) REFERENCES monitors(slug)
@ -41,8 +43,8 @@ CREATE TABLE monitor_worker_groups (
CREATE TABLE monitor_histories ( CREATE TABLE monitor_histories (
monitor_slug TEXT, monitor_slug TEXT,
status TEXT, status TEXT,
note TEXT, note TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP, created_at DATETIME DEFAULT CURRENT_TIMESTAMP,

View file

@ -17,8 +17,8 @@ primary_region = 'waw'
ROOT_URL = 'https://zdravko.mnts.dev' ROOT_URL = 'https://zdravko.mnts.dev'
TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233' TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233'
TEMPORAL_DATABASE_PATH = '/data/temporal-5.db' TEMPORAL_DATABASE_PATH = '/data/temporal-6.db'
DATABASE_PATH = '/data/zdravko-5.db' DATABASE_PATH = '/data/zdravko-6.db'
[processes] [processes]
server = '--temporal --server' server = '--temporal --server'

View file

@ -16,7 +16,7 @@ func CreateOAuth2State(ctx context.Context, db *sqlx.DB, oauth2State *models.OAu
} }
func DeleteOAuth2State(ctx context.Context, db *sqlx.DB, state string) (deleted bool, err error) { func DeleteOAuth2State(ctx context.Context, db *sqlx.DB, state string) (deleted bool, err error) {
res, err := db.ExecContext(ctx, "DELETE FROM oauth2_states WHERE state = $1 AND expires_at > NOW()", state) res, err := db.ExecContext(ctx, "DELETE FROM oauth2_states WHERE state = $1 AND expires_at > datetime('now')", state)
if err != nil { if err != nil {
return false, err return false, err
} }