feat: persist preferred project by account key#1366
Merged
jonathanlab merged 1 commit intomainfrom Apr 1, 2026
Merged
Conversation
This was referenced Mar 30, 2026
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
87a631f to
464aeac
Compare
ddd1bec to
f3b186c
Compare
1b8363f to
3d93c97
Compare
f3b186c to
1e35e6d
Compare
k11kirky
approved these changes
Mar 31, 2026
Comment on lines
+1
to
+7
| CREATE TABLE `auth_preferences` ( | ||
| `account_key` text NOT NULL, | ||
| `cloud_region` text NOT NULL, | ||
| `last_selected_project_id` integer, | ||
| `created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL, | ||
| `updated_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL | ||
| ); |
There was a problem hiding this comment.
The auth_preferences table is missing a PRIMARY KEY or UNIQUE constraint on (account_key, cloud_region). This will allow duplicate rows to be inserted for the same account and region combination, causing unpredictable behavior in the get and save methods.
Impact: Multiple preference records can exist for the same account/region, and LIMIT 1 queries will return arbitrary rows. The update logic in save() may also fail to work correctly.
Fix: Add a composite primary key:
CREATE TABLE `auth_preferences` (
`account_key` text NOT NULL,
`cloud_region` text NOT NULL,
`last_selected_project_id` integer,
`created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL,
`updated_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL,
PRIMARY KEY (`account_key`, `cloud_region`)
);
Suggested change
| CREATE TABLE `auth_preferences` ( | |
| `account_key` text NOT NULL, | |
| `cloud_region` text NOT NULL, | |
| `last_selected_project_id` integer, | |
| `created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL, | |
| `updated_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL | |
| ); | |
| CREATE TABLE `auth_preferences` ( | |
| `account_key` text NOT NULL, | |
| `cloud_region` text NOT NULL, | |
| `last_selected_project_id` integer, | |
| `created_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL, | |
| `updated_at` text DEFAULT (CURRENT_TIMESTAMP) NOT NULL, | |
| PRIMARY KEY (`account_key`, `cloud_region`) | |
| ); | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
1e35e6d to
7255c9c
Compare
6df4db0 to
03cfd87
Compare
Contributor
Author
Merge activity
|
jonathanlab
added a commit
that referenced
this pull request
Apr 1, 2026
## Problem We've now hooked up our main services to the auth service, but the auth store is just a thin unreliable wrapper around the main service. We want to rely on trpc queries with tanstack query instead. <!-- Who is this for and what problem does it solve? --> <!-- Closes #ISSUE_ID --> ## Changes - Gets rid of the auth store - Moves onboarding logic into its own store - Moves auth ui state into its own store - Add a bunch of hooks for querying and mutating the auth state via the main auth service ------- one test fails here (preferred org persistence), we can just forge merge with CI bypass this one since it's fixed in the [next PR](#1366) in the stack
03cfd87 to
0fb87ee
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Problem
Now we're not persisting preferred project on logout followed by login
Changes
persist it in sqlite, keying by region and account key