-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
149 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
1 change: 1 addition & 0 deletions
1
examples/users/migrations/1733765331409957000_rwf_auth_users.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE rwf_auth_users; |
8 changes: 8 additions & 0 deletions
8
examples/users/migrations/1733765331409957000_rwf_auth_users.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE TABLE rwf_auth_users ( | ||
id BIGSERIAL PRIMARY KEY, | ||
identifier VARCHAR NOT NULL UNIQUE, | ||
password VARCHAR NOT NULL, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW () | ||
); | ||
|
||
CREATE INDEX ON rwf_auth_users USING btree (created_at); |
3 changes: 3 additions & 0 deletions
3
examples/users/migrations/1733778837089567000_rwf_init.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP TABLE IF EXISTS rwf_requests; | ||
|
||
DROP TABLE IF EXISTS rwf_jobs; |
45 changes: 45 additions & 0 deletions
45
examples/users/migrations/1733778837089567000_rwf_init.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_jobs ( | ||
id BIGSERIAL PRIMARY KEY, | ||
name VARCHAR NOT NULL, | ||
args JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
start_after TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
started_at TIMESTAMPTZ, | ||
attempts INT NOT NULL DEFAULT 0, | ||
retries BIGINT NOT NULL DEFAULT 25, | ||
completed_at TIMESTAMPTZ, | ||
error VARCHAR | ||
); | ||
|
||
-- Pending jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_pending_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NULL | ||
AND attempts < retries; | ||
|
||
-- Running jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_runnin_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NOT NULL | ||
AND attempts < retries; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_jobs_name_completed_at_idx ON rwf_jobs USING btree(name, completed_at); | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_requests ( | ||
id BIGSERIAL PRIMARY KEY, | ||
path VARCHAR NOT NULL, | ||
method VARCHAR NOT NULL DEFAULT 'GET', | ||
query JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
code INTEGER NOT NULL DEFAULT 200, | ||
client_ip INET, | ||
client_id UUID NOT NULL DEFAULT gen_random_uuid(), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
duration REAL NOT NULL | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_path_created_at ON rwf_requests USING btree(created_at, path, client_id); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_errors ON rwf_requests USING btree(created_at, code, client_id) WHERE code >= 400; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_too_slow ON rwf_requests USING btree(created_at, duration, client_id) WHERE duration >= 1000.0; -- the unit is milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[general] | ||
secret_key = "9Sk2t2G40QC3QrdVr6e6RzYAKJLGTFjpDiRrmA7eGQk=" | ||
log_queries = true | ||
# log_queries = true | ||
|
||
[database] | ||
name = "rwf_users" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ homepage = "https://levkk.github.io/rwf/" | |
repository = "https://github.com/levkk/rwf" | ||
keywords = ["mvc", "web", "framework", "http", "orm"] | ||
authors = ["Lev Kokotov <[email protected]>"] | ||
include = ["src/", "migrations/"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP TABLE IF EXISTS rwf_requests; | ||
|
||
DROP TABLE IF EXISTS rwf_jobs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_jobs ( | ||
id BIGSERIAL PRIMARY KEY, | ||
name VARCHAR NOT NULL, | ||
args JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
start_after TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
started_at TIMESTAMPTZ, | ||
attempts INT NOT NULL DEFAULT 0, | ||
retries BIGINT NOT NULL DEFAULT 25, | ||
completed_at TIMESTAMPTZ, | ||
error VARCHAR | ||
); | ||
|
||
-- Pending jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_pending_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NULL | ||
AND attempts < retries; | ||
|
||
-- Running jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_runnin_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NOT NULL | ||
AND attempts < retries; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_jobs_name_completed_at_idx ON rwf_jobs USING btree(name, completed_at); | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_requests ( | ||
id BIGSERIAL PRIMARY KEY, | ||
path VARCHAR NOT NULL, | ||
method VARCHAR NOT NULL DEFAULT 'GET', | ||
query JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
code INTEGER NOT NULL DEFAULT 200, | ||
client_ip INET, | ||
client_id UUID NOT NULL DEFAULT gen_random_uuid(), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
duration REAL NOT NULL | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_path_created_at ON rwf_requests USING btree(created_at, path, client_id); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_errors ON rwf_requests USING btree(created_at, code, client_id) WHERE code >= 400; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_too_slow ON rwf_requests USING btree(created_at, duration, client_id) WHERE duration >= 1000.0; -- the unit is milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,9 @@ | ||
SET LOCAL client_min_messages TO WARNING; | ||
SET | ||
LOCAL client_min_messages TO WARNING; | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_migrations ( | ||
id BIGSERIAL PRIMARY KEY, | ||
version BIGINT NOT NULL, | ||
name VARCHAR UNIQUE NOT NULL, | ||
applied_at TIMESTAMPTZ | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_jobs ( | ||
id BIGSERIAL PRIMARY KEY, | ||
name VARCHAR NOT NULL, | ||
args JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
start_after TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
started_at TIMESTAMPTZ, | ||
attempts INT NOT NULL DEFAULT 0, | ||
retries BIGINT NOT NULL DEFAULT 25, | ||
completed_at TIMESTAMPTZ, | ||
error VARCHAR | ||
version BIGINT NOT NULL, | ||
name VARCHAR UNIQUE NOT NULL, | ||
applied_at TIMESTAMPTZ | ||
); | ||
|
||
-- Pending jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_pending_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NULL | ||
AND attempts < retries; | ||
|
||
-- Running jobs | ||
CREATE INDEX IF NOT EXISTS rwf_jobs_runnin_idx ON rwf_jobs USING btree(start_after, created_at) WHERE | ||
completed_at IS NULL | ||
AND started_at IS NOT NULL | ||
AND attempts < retries; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_jobs_name_completed_at_idx ON rwf_jobs USING btree(name, completed_at); | ||
|
||
CREATE TABLE IF NOT EXISTS rwf_requests ( | ||
id BIGSERIAL PRIMARY KEY, | ||
path VARCHAR NOT NULL, | ||
method VARCHAR NOT NULL DEFAULT 'GET', | ||
query JSONB NOT NULL DEFAULT '{}'::jsonb, | ||
code INTEGER NOT NULL DEFAULT 200, | ||
client_ip INET, | ||
client_id UUID NOT NULL DEFAULT gen_random_uuid(), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
duration REAL NOT NULL | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_path_created_at ON rwf_requests USING btree(created_at, path, client_id); | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_errors ON rwf_requests USING btree(created_at, code, client_id) WHERE code >= 400; | ||
|
||
CREATE INDEX IF NOT EXISTS rwf_requests_too_slow ON rwf_requests USING btree(created_at, duration, client_id) WHERE duration >= 1000.0; -- the unit is milliseconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters