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
CREATE TABLE oauth2_states (
state TEXT,
expiry DATETIME,
state TEXT,
expires_at DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (state)
);
@ -33,7 +34,8 @@ CREATE TABLE worker_groups (
CREATE TABLE monitor_worker_groups (
worker_group_slug TEXT,
monitor_slug TEXT,
monitor_slug TEXT,
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_monitor FOREIGN KEY (monitor_slug) REFERENCES monitors(slug)
@ -41,8 +43,8 @@ CREATE TABLE monitor_worker_groups (
CREATE TABLE monitor_histories (
monitor_slug TEXT,
status TEXT,
note TEXT,
status TEXT,
note TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,

View file

@ -17,8 +17,8 @@ primary_region = 'waw'
ROOT_URL = 'https://zdravko.mnts.dev'
TEMPORAL_SERVER_HOST = 'server.process.zdravko.internal:7233'
TEMPORAL_DATABASE_PATH = '/data/temporal-5.db'
DATABASE_PATH = '/data/zdravko-5.db'
TEMPORAL_DATABASE_PATH = '/data/temporal-6.db'
DATABASE_PATH = '/data/zdravko-6.db'
[processes]
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) {
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 {
return false, err
}