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

28 lines
769 B
MySQL
Raw Normal View History

2022-07-28 02:47:40 -04:00
-- 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`
2022-07-29 00:01:01 -04:00
ADD FOREIGN KEY (`client_uid`) REFERENCES `clients` (`uid`);
ALTER TABLE `sessions`
CHANGE `id` `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;