This repository has been archived on 2023-11-14. You can view files and clone it, but cannot push or open issues/pull-requests.
viscord/packages/server/public/migrations/8-sessions.sql

25 lines
676 B
SQL

-- 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`)