-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(auth, gateway): use user_id over account_name (#1674)
* feat(auth): user_id not null, remove migration insertions * fix(auth): insert user_id on command inserts * feat: rename account_name to user_id in most places * nits * nit2 * fix: auth tests almost working * yeet: auth/refresh * fix: span * fix: auth tests * feat: set old account name header for tracing in old deployers * nit: clarify start_last_deploy * fix: sql comment * fix: userid comment * feat(deployer): use claim instead of user id header for tracing * nit: remove request.path tracing field * Revert "nit: remove request.path tracing field" This reverts commit 0be50c3. * less clone * feat(auth): keep get account by name endpoint * fmt * ci: unstable * clippy * fix: migration drift fixes * fix: migration drift fixes 2 * revert: migration drift fixes * fix: endpoint ordering * test: set empty field on endpoint * Revert "test: set empty field on endpoint" This reverts commit bc82a89.
- Loading branch information
Showing
22 changed files
with
325 additions
and
414 deletions.
There are no files selected for viewing
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,27 @@ | ||
-- All rows should have user_ids at this point (added in the application logic before this migration was introduced) | ||
ALTER TABLE users | ||
ALTER COLUMN user_id SET NOT NULL; | ||
|
||
|
||
-- Switch the foreign key(fk) on subscriptions and remove the old fk | ||
ALTER TABLE subscriptions | ||
ADD COLUMN user_id TEXT; | ||
|
||
UPDATE subscriptions | ||
SET user_id = users.user_id | ||
FROM users | ||
WHERE subscriptions.account_name = users.account_name; | ||
|
||
ALTER TABLE subscriptions | ||
DROP CONSTRAINT subscriptions_account_name_fkey, | ||
ADD FOREIGN KEY (user_id) REFERENCES users (user_id), | ||
ALTER COLUMN user_id SET NOT NULL, | ||
DROP COLUMN account_name, | ||
-- Add back the unique pair constraint | ||
ADD CONSTRAINT user_id_type UNIQUE (user_id, type); | ||
|
||
|
||
-- Switch the primary key on users | ||
ALTER TABLE users | ||
DROP CONSTRAINT users_pkey, | ||
ADD PRIMARY KEY (user_id); |
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
Oops, something went wrong.