-- AlterTable ALTER TABLE `users` ADD COLUMN `isGuest` BOOLEAN NOT NULL DEFAULT false; -- CreateIndex CREATE INDEX `idx_users_is_guest` ON `users`(`isGuest`); -- CreateTable CREATE TABLE `auth_identities` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `userId` BIGINT UNSIGNED NOT NULL, `provider` ENUM('password', 'guest') NOT NULL, `providerSubject` VARCHAR(191) NOT NULL, `email` VARCHAR(191) NULL, `passwordHash` VARCHAR(255) NULL, `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updatedAt` DATETIME(3) NOT NULL, UNIQUE INDEX `uq_auth_identities_provider_subject`(`provider`, `providerSubject`), INDEX `idx_auth_identities_user_id`(`userId`), INDEX `idx_auth_identities_email`(`email`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- CreateTable CREATE TABLE `auth_sessions` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `userId` BIGINT UNSIGNED NOT NULL, `tokenHash` CHAR(64) NOT NULL, `expiresAt` DATETIME(3) NOT NULL, `revokedAt` DATETIME(3) NULL, `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updatedAt` DATETIME(3) NOT NULL, UNIQUE INDEX `auth_sessions_tokenHash_key`(`tokenHash`), INDEX `idx_auth_sessions_user_id_expires_at`(`userId`, `expiresAt`), INDEX `idx_auth_sessions_expires_at`(`expiresAt`), PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- AddForeignKey ALTER TABLE `auth_identities` ADD CONSTRAINT `auth_identities_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `auth_sessions` ADD CONSTRAINT `auth_sessions_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;