-
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
Changes from 23 commits
d69e9c0
c75a0df
f53a93c
d5612b1
70b2349
941ec36
7327209
d0a562c
8ddcbdd
f477e90
6655c5f
bb2b9d7
5869fca
72bae7b
d52f5b3
8d01f31
49abe22
33956e5
332df23
65f36c0
e4208b2
9d82ae7
435fe4b
c17bdc5
61960d1
fd30525
4eed892
2203fb9
File filter
Filter by extension
Conversations
Jump to
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.
| 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 (1) ON CONFLICT DO NOTHING; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Any objection to starting with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just chose 1 because SQL sequences start at 1. Let me know what you prefer and I'll change it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think 0 would be better because we wouldn’t index into a SQL sequence. But, it’s not a hill I’m willing to die on either as it’s not too hard to throw a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to 0 in 2203fb9. |
||
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!