diff --git a/database/sqlite/migrations/2024-02-27-initial.sql b/database/sqlite/migrations/2024-02-27-initial.sql index cd4fbde..3a4e305 100644 --- a/database/sqlite/migrations/2024-02-27-initial.sql +++ b/database/sqlite/migrations/2024-02-27-initial.sql @@ -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, diff --git a/deploy/fly.toml b/deploy/fly.toml index 506100d..ffc54b6 100644 --- a/deploy/fly.toml +++ b/deploy/fly.toml @@ -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' diff --git a/internal/services/oauth2_state.go b/internal/services/oauth2_state.go index 1572f5c..9894685 100644 --- a/internal/services/oauth2_state.go +++ b/internal/services/oauth2_state.go @@ -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 }