Skip to content

Commit

Permalink
feat(webhooks): allow enabling/disabling responders
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Mar 26, 2024
1 parent 9fe5780 commit 35965fc
Show file tree
Hide file tree
Showing 17 changed files with 459 additions and 102 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions migrations/20240126235917_v1.0.0-beta.1.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
-- Update `users` table to delete `roles` column (replaced by subscription).
ALTER TABLE users DROP COLUMN roles;
ALTER TABLE users
DROP COLUMN roles;

-- Upgrade scheduler table to add `time_offset_seconds` column (`tokio-cron-scheduler 0.10.0`).
ALTER TABLE main.scheduler_jobs ADD time_offset_seconds INTEGER;
ALTER TABLE scheduler_jobs
ADD time_offset_seconds INTEGER;

-- Upgrade `user_data_webhooks_responders` table to add `enabled` column (defaults to `1`).
ALTER TABLE user_data_webhooks_responders
ADD enabled INTEGER NOT NULL DEFAULT 1;

-- Create table to store user subscriptions.
CREATE TABLE IF NOT EXISTS user_subscriptions
(
tier INTEGER NOT NULL,
started_at INTEGER NOT NULL,
ends_at INTEGER,
trial_started_at INTEGER,
trial_ends_at INTEGER,
user_id INTEGER NOT NULL UNIQUE REFERENCES users(id) ON DELETE CASCADE,
CHECK ((ends_at IS NULL OR (ends_at > started_at)) AND (trial_started_at IS NULL OR trial_ends_at IS NULL OR (trial_ends_at > trial_started_at)))
tier INTEGER NOT NULL,
started_at INTEGER NOT NULL,
ends_at INTEGER,
trial_started_at INTEGER,
trial_ends_at INTEGER,
user_id INTEGER NOT NULL UNIQUE REFERENCES users (id) ON DELETE CASCADE,
CHECK ((ends_at IS NULL OR (ends_at > started_at)) AND
(trial_started_at IS NULL OR trial_ends_at IS NULL OR (trial_ends_at > trial_started_at)))
) STRICT;

-- Create subscription for all existing users (basic tier + 14 days of trial).
INSERT INTO user_subscriptions (user_id, tier, started_at, trial_started_at, trial_ends_at)
SELECT id, 10, created, unixepoch(), (unixepoch() + 14 * 24 * 60 * 60)
FROM users
FROM users
WHERE true
ON CONFLICT(user_id) DO NOTHING;
2 changes: 1 addition & 1 deletion src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod utils_resource_log_context;

pub use self::{
job_log_context::JobLogContext, metrics_context::MetricsContext,
user_log_context::UserLogContext,
user_log_context::UserLogContext, utils_resource_log_context::UtilsResourceLogContext,
};

#[cfg(test)]
Expand Down
Loading

0 comments on commit 35965fc

Please sign in to comment.