aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-server-sqlite/src/lib.rs (unfollow)
Commit message (Collapse)Author
3 dayschore: Move everything into one big crateBenedikt Peetz
That helps remove duplicated code and rustc/cargo will now also show dead code correctly.
2026-05-14refactor: pull `fn into_utc` into atuin-server-database crate (#3487)John Oxley
The `fn into_utc` was defined in both `atuin-server-postgres` and `atuin-server-sqlite`, with tests being in the postgres crate. This pulls the function into the `atuin-server-database` crate along with the tests and references it from both crates. ## Checks - [X] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [X] I have checked that there are no existing pull requests for the same thing
2026-05-14refactor: Implement From<sqlx::Error> and clean up fix_error (#3484)John Oxley
In the database crates for atuin-server, there is `fn fix_error`. This PR implements `From<sqlx::Error>` on `DbError` which makes it possible to mostly use `?` to bubble up the errors. There are cases where `?` is not being used e.g. ```rust async fn get_session(&self, token: &str) -> DbResult<Session> { sqlx::query_as("select id, user_id, token from sessions where token = $1") .bind(token) .fetch_one(&self.pool) .await .map_err(fix_error) .map(|DbSession(session)| session) } ``` There are two options ## 1. Use `Into::into` ```rust async fn get_session(&self, token: &str) -> DbResult<Session> { sqlx::query_as("select id, user_id, token from sessions where token = $1") .bind(token) .fetch_one(&self.pool) .await .map_err(fix_error) .map(|DbSession(session)| session) } ``` ## 2. Create a variable and use `?` ```rust async fn get_session(&self, token: &str) -> DbResult<Session> { let session = sqlx::query_as("select id, user_id, token from sessions where token = $1") .bind(token) .fetch_one(&self.pool) .await .map(|DbSession(session)| session)?; Ok(session) } ``` I chose to do option 1 as it was just a find/replace but say the word and I'll convert them all to option 2 ## Checks - [X] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [X] I have checked that there are no existing pull requests for the same thing
2026-01-27feat: remove user verification functionality (#3108)Ellie Huxtable
<!-- Thank you for making a PR! Bug fixes are always welcome, but if you're adding a new feature or changing an existing one, we'd really appreciate if you open an issue, post on the forum, or drop in on Discord --> ## Checks - [ ] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [ ] I have checked that there are no existing pull requests for the same thing --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-01-23chore!: remove total_history from api index response (#3094)Ellie Huxtable
Remove the expensive and inaccurate `total_history` field from the API index endpoint. The query `select sum(total) from total_history_count_user` ran on every request but is no longer relevant. The underlying table remains for per-user cached counts used by `/sync/count`. ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing
2025-06-23feat: Add sqlite server support for self-hosting (#2770)Scotte Zinn
* Move db_uri setting to DbSettings * WIP: sqlite crate framework * WIP: Migrations * WIP: sqlite implementation * Add sqlite3 to Docker image * verified_at needed for user query * chore(deps): bump debian (#2772) Bumps debian from bookworm-20250428-slim to bookworm-20250520-slim. --- updated-dependencies: - dependency-name: debian dependency-version: bookworm-20250520-slim dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix(doctor): mention the required ble.sh version (#2774) References: https://forum.atuin.sh/t/1047 * fix: Don't print errors in `zsh_autosuggest` helper (#2780) Previously, this would result in long multi-line errors when typing, making it hard to see the shell prompt: ``` $ Error: could not load client settings Caused by: 0: could not create config file 1: failed to create file `/home/jyn/.config/atuin/config.toml` 2: Required key not available (os error 126) Location: atuin-client/src/settings.rs:675:54 fError: could not load client settings Caused by: 0: could not create config file 1: failed to create file `/home/jyn/.config/atuin/config.toml` 2: Required key not available (os error 126) Location: atuin-client/src/settings.rs:675:54 faError: could not load client settings ``` Silence these in autosuggestions, such that they only show up when explicitly invoking atuin. * fix: `atuin.nu` enchancements (#2778) * PR feedback * Remove sqlite3 package * fix(search): prevent panic on malformed format strings (#2776) (#2777) * fix(search): prevent panic on malformed format strings (#2776) - Wrap format operations in panic catcher for graceful error handling - Improve error messages with context-aware guidance for common issues - Let runtime-format parser handle validation to avoid blocking valid formats Fixes crash when using malformed format strings by catching formatting errors gracefully and providing actionable guidance without restricting legitimate format patterns like {command} or {time}. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Satisfy cargo fmt * test(search): add regression tests for format string panic (#2776) - Add test for malformed JSON format strings that previously caused panics - Add test to ensure valid format strings continue to work - Prevent future regressions of the format string panic issue 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Koichi Murase <myoga.murase@gmail.com> Co-authored-by: jyn <github@jyn.dev> Co-authored-by: Tyarel8 <98483313+Tyarel8@users.noreply.github.com> Co-authored-by: Brian Cosgrove <cosgroveb@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
2025-03-19chore: migrate to rust 2024 (#2635)Ellie Huxtable
* chore: upgrade to 2024 edition * ugh unsafe * format * nixxxxxxxxxxx why
2024-07-03fix: ambiguous column name (#2232)Ellie Huxtable
2024-07-03fix: idx cache inconsistency (#2231)Ellie Huxtable
2024-07-02feat: monitor idx cache consistency before switching (#2229)Ellie Huxtable
2024-07-02perf: write to the idx cache (#2225)Ellie Huxtable
2024-06-24fix: ensure we cleanup all tables when deleting (#2191)Ellie Huxtable
2024-06-24feat: add user account verification (#2190)Ellie Huxtable
* add verified column to users table * add database functions to check if verified, or to verify * getting there * verification check * use base64 urlsafe no pad * add verification client * clippy * correct docs * fix integration tests
2024-05-21fix: redact password in database URI when logging (#2032)Jeremy Cline
Previously, in the event that there was a configuration issue and the atuin server failed to connect to PostgreSQL, it would log the password. For example, if the password authentication failed the following log message would be printed: Error: failed to connect to db: PostgresSettings { db_uri: "postgres://atuin:definitelymypassword@db.example.com/atuin" } This change sets the password to "****" when printing it via Debug: Error: failed to connect to db: PostgresSettings { db_uri: "postgres://atuin:****@db.example.com/atuin" } Hopefully few people use **** as the actual password.
2024-04-18chore: move crates into crates/ dir (#1958)Ellie Huxtable
I'd like to tidy up the root a little, and it's nice to have all the rust crates in one place
2024-03-12feat(server): check PG version before running migrations (#1868)Xavier Vello
2024-02-02feat: add `store push --force`Ellie Huxtable
This will 1. Wipe the remote store 2. Upload all of the local store to remote Imagine the scenario where you end up with some mixed keys locally :( You confirm this with ``` atuin store verify ``` You then fix it locally with ``` atuin store purge ``` Ensure that your local changes are reflected remotely with ``` atuin store push --force ``` and then (another PR, coming soon), update all other hosts with ``` atuin store pull --force ```
2024-01-29feat: Add change-password command & support on server (#1615)TymanWasTaken
* Add change-password command & support on server * Add a test for password change * review: run format --------- Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2024-01-05feat: rework record sync for improved reliability (#1478)Ellie Huxtable
* feat: rework record sync for improved reliability So, to tell a story 1. We introduced the record sync, intended to be the new algorithm to sync history. 2. On top of this, I added the KV store. This was intended as a simple test of the record sync, and to see if people wanted that sort of functionality 3. History remained syncing via the old means, as while it had issues it worked more-or-less OK. And we are aware of its flaws 4. If KV syncing worked ok, history would be moved across KV syncing ran ok for 6mo or so, so I started to move across history. For several weeks, I ran a local fork of Atuin + the server that synced via records instead. The record store maintained ordering via a linked list, which was a mistake. It performed well in testing, but was really difficult to debug and reason about. So when a few small sync issues occured, they took an extremely long time to debug. This PR is huge, which I regret. It involves replacing the "parent" relationship that records once had (pointing to the previous record) with a simple index (generally referred to as idx). This also means we had to change the recordindex, which referenced "tails". Tails were the last item in the chain. Now that we use an "array" vs linked list, that logic was also replaced. And is much simpler :D Same for the queries that act on this data. ---- This isn't final - we still need to add 1. Proper server/client error handling, which has been lacking for a while 2. The actual history implementation on top This exists in a branch, just without deletions. Won't be much to add that, I just don't want to make this any larger than it already is The _only_ caveat here is that we basically lose data synced via the old record store. This is the KV data from before. It hasn't been deleted or anything, just no longer hooked up. So it's totally possible to write a migration script. I just need to do that. * update .gitignore * use correct endpoint * fix for stores with length of 1 * use create/delete enum for history store * lint, remove unneeded host_id * remove prints * add command to import old history * add enable/disable switch for record sync * add record sync to auto sync * satisfy the almighty clippy * remove file that I did not mean to commit * feedback
2023-09-29support timezones in calendar (#1259)Conrad Ludgate
2023-09-28fix sync timestamps (#1258)Conrad Ludgate
* fix timestamp * add sync test * skip all sync tests
2023-09-11replace chrono with time (#806)Conrad Ludgate
* replace chrono with time * Fix test chrono usage --------- Co-authored-by: Ellie Huxtable <ellie@elliehuxtable.com>
2023-08-18Update dependencies (#1181)Conrad Ludgate
2023-08-09Fix index tail leak (#1159)Ellie Huxtable
2023-07-14Delete the count cache row when a user is deleted (#1103)Ellie Huxtable
2023-07-14Add total history count to the index API (#1102)Ellie Huxtable
Thought it would be fun to collect some cool stats, maybe put them on atuin.sh.
2023-07-14Add new sync (#1093)Ellie Huxtable
* Add record migration * Add database functions for inserting history No real tests yet :( I would like to avoid running postgres lol * Add index handler, use UUIDs not strings * Fix a bunch of tests, remove Option<Uuid> * Add tests, all passing * Working upload sync * Record downloading works * Sync download works * Don't waste requests * Use a page size for uploads, make it variable later * Aaaaaand they're encrypted now too * Add cek * Allow reading tail across hosts * Revert "Allow reading tail across hosts" Not like that This reverts commit 7b0c72e7e050c358172f9b53cbd21b9e44cf4931. * Handle multiple shards properly * format * Format and make clippy happy * use some fancy types (#1098) * use some fancy types * fmt * Goodbye horrible tuple * Update atuin-server-postgres/migrations/20230623070418_records.sql Co-authored-by: Conrad Ludgate <conradludgate@gmail.com> * fmt * Sort tests too because time sucks * fix features --------- Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
2023-06-12refactor server to allow pluggable db and tracing (#1036)Conrad Ludgate
* refactor server to allow pluggable db and tracing * clean up * fix descriptions * remove dependencies