save oauth user_id and link users and accounts
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
-- save the oauth user_id to keep track of all known users, and to link to accounts.
|
||||
|
||||
CREATE TABLE oauth_users (
|
||||
user_id TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY (user_id)
|
||||
);
|
||||
|
||||
INSERT INTO oauth_users (
|
||||
user_id
|
||||
)
|
||||
SELECT
|
||||
DISTINCT id_token_subject
|
||||
FROM
|
||||
oauth_tokens;
|
||||
|
||||
ALTER TABLE oauth_tokens
|
||||
ADD CONSTRAINT fk_oauth_tokens_oauth_users
|
||||
FOREIGN KEY (id_token_subject)
|
||||
REFERENCES oauth_users (user_id);
|
||||
|
||||
ALTER TABLE accounts
|
||||
ADD COLUMN user_id TEXT
|
||||
UNIQUE
|
||||
REFERENCES oauth_users (user_id) NOT NULL;
|
||||
Reference in New Issue
Block a user