-
Notifications
You must be signed in to change notification settings - Fork 26
feature(pedm): SQL initialization #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d69e9c0
refactor(pedm): modify `serve` arguments
allan2 c75a0df
Fix Linux build
allan2 f53a93c
Fix api module publicity
allan2 d5612b1
feature(pedm): SQL initialization
allan2 70b2349
Merge branch pedm-sql-init into pedm-sql-init3
allan2 941ec36
Unformat Cargo.toml
allan2 7327209
Update Cargo.lock
allan2 d0a562c
Restore Cargo.toml; fix merge issue
allan2 8ddcbdd
Update Cargo.lock
allan2 f477e90
Correct typo
allan2 6655c5f
Fetch integer as i64
allan2 bb2b9d7
Merge origin/master
allan2 5869fca
Remove extra line
allan2 72bae7b
Rename tables
allan2 d52f5b3
Style: variable name
allan2 8d01f31
fmt
allan2 49abe22
Use `self::` when importing from current module
allan2 33956e5
Minor fmt and doc changes
allan2 332df23
fmt
allan2 65f36c0
Fix bug in LogLayer
allan2 e4208b2
Remove unnecessary unwrap
allan2 9d82ae7
Rename request count in `/about`
allan2 435fe4b
Update Cargo.lock
allan2 c17bdc5
Rename request counts in `AboutData`
allan2 61960d1
Reorder imports
allan2 fd30525
Rename `init_schema` to `setup` on `Db` wrapper
allan2 4eed892
Add pragma placeholder
allan2 2203fb9
Change initial schema version to 0
allan2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
This file contains hidden or 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 hidden or 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,20 +1,39 @@ | ||
| /* In SQLite, we store time as integer with microsecond precision. This is the same precision used by TIMESTAMPTZ in Postgres. */ | ||
| /* In SQLite, we store time as an 8-byte integer (i64) with microsecond precision. This matches TIMESTAMPTZ in Postgres. | ||
| Use `chrono::DateTime::timestamp_micros` when inserting or fetching timestamps in Rust. | ||
| */ | ||
|
|
||
| CREATE TABLE pedm_run ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| start_time INTEGER NOT NULL DEFAULT (CAST(strftime('%f', 'now') * 1000000 AS INTEGER)), | ||
| pipe_name TEXT NOT NULL | ||
| CREATE TABLE IF NOT EXISTS version | ||
| ( | ||
| version integer PRIMARY KEY, | ||
| updated_at integer NOT NULL DEFAULT ( | ||
| CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000 | ||
| ) | ||
| ); | ||
|
|
||
| CREATE TABLE http_request ( | ||
| id INTEGER PRIMARY KEY, | ||
| at INTEGER NOT NULL DEFAULT (CAST(strftime('%f', 'now') * 1000000 AS INTEGER)), | ||
| method TEXT NOT NULL, | ||
| path TEXT NOT NULL, | ||
| status_code INTEGER NOT NULL | ||
| CREATE TABLE IF NOT EXISTS run | ||
| ( | ||
| id integer PRIMARY KEY AUTOINCREMENT, | ||
| start_time integer NOT NULL DEFAULT ( | ||
| CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000 | ||
| ), | ||
| pipe_name text NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE elevate_tmp_request ( | ||
| req_id INTEGER PRIMARY KEY, | ||
| seconds INTEGER NOT NULL | ||
| CREATE TABLE IF NOT EXISTS http_request | ||
| ( | ||
| id integer PRIMARY KEY, | ||
| at integer NOT NULL DEFAULT ( | ||
| CAST(strftime('%s', 'now') AS integer) * 1000000 + CAST(strftime('%f', 'now') * 1000000 AS integer) % 1000000 | ||
| ), | ||
| method text NOT NULL, | ||
| path text NOT NULL, | ||
| status_code integer NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS elevate_tmp_request | ||
| ( | ||
| req_id integer PRIMARY KEY, | ||
| seconds integer NOT NULL | ||
| ); | ||
|
|
||
| INSERT INTO version (version) VALUES (0) ON CONFLICT DO NOTHING; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is there some rationale for when the
pedmprefix is used in table names?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was in case the database is also used by Gateway or other programs in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. The table naming is inconsistent. And I can't see other programs using this specific
http_requesttable.Tables are renamed in 72bae7b. The database is meant for isolated PEDM usage. This is expressed in the example config, with a database name of
pedmor file ofpedm.sqlite.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s better to use a different database completely! 🙂
I agree with the way you renamed the tables!