some token SQL

main
Valerie 2022-07-28 02:47:40 -04:00
parent a1784f5cb2
commit 30ebc0fcf1
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,25 @@
-- add usernames, separate
-- from display name! (this is for uniqueness)
ALTER TABLE `clients`
ADD `username` varchar(256) COLLATE 'utf8mb4_general_ci' NOT NULL;
-- set all previous accounts usernames to their uid
-- as its unique, and now powerless for authentication.
UPDATE clients
SET clients.username=clients.uid;
-- make username unique
ALTER TABLE `clients`
ADD UNIQUE `username` (`username`);
-- create sessions w FK to clients
CREATE TABLE `sessions` (
`id` int NOT NULL,
`client_uid` varchar(36) NOT NULL,
`expires` bigint(20) NOT NULL,
`token` varchar(512) NOT NULL
);
ALTER TABLE `sessions`
ADD FOREIGN KEY (`client_uid`) REFERENCES `clients` (`uid`)

View File

@ -0,0 +1,2 @@
INSERT INTO sessions (client_uid, expires, token)
VALUES (?, ?, ?);