mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-07-10 11:06:23 +02:00
112 lines
4.9 KiB
SQL
112 lines
4.9 KiB
SQL
-- PHP-Auth (https://github.com/delight-im/PHP-Auth)
|
|
-- Copyright (c) delight.im (https://www.delight.im/)
|
|
-- Licensed under the MIT License (https://opensource.org/licenses/MIT)
|
|
|
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
/*!40101 SET NAMES utf8mb4 */;
|
|
|
|
CREATE TABLE `users` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`email` varchar(249) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
`password` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`username` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`status` tinyint unsigned NOT NULL DEFAULT '0',
|
|
`verified` tinyint unsigned NOT NULL DEFAULT '0',
|
|
`resettable` tinyint unsigned NOT NULL DEFAULT '1',
|
|
`roles_mask` int unsigned NOT NULL DEFAULT '0',
|
|
`registered` int unsigned NOT NULL,
|
|
`last_login` int unsigned DEFAULT NULL,
|
|
`force_logout` mediumint unsigned NOT NULL DEFAULT '0',
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `email` (`email`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_2fa` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned NOT NULL,
|
|
`mechanism` tinyint unsigned NOT NULL,
|
|
`seed` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`created_at` int unsigned NOT NULL,
|
|
`expires_at` int unsigned DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `user_id_mechanism` (`user_id`,`mechanism`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_audit_log` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned DEFAULT NULL,
|
|
`event_at` int unsigned NOT NULL,
|
|
`event_type` varchar(128) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
|
|
`admin_id` int unsigned DEFAULT NULL,
|
|
`ip_address` varchar(49) CHARACTER SET ascii COLLATE ascii_general_ci DEFAULT NULL,
|
|
`user_agent` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
`details_json` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `event_at` (`event_at`),
|
|
KEY `user_id_event_at` (`user_id`,`event_at`),
|
|
KEY `user_id_event_type_event_at` (`user_id`,`event_type`,`event_at`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_confirmations` (
|
|
`id` int unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned NOT NULL,
|
|
`email` varchar(249) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
`selector` varchar(16) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`expires` int unsigned NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `selector` (`selector`),
|
|
KEY `email_expires` (`email`,`expires`),
|
|
KEY `user_id` (`user_id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_otps` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`user_id` int unsigned NOT NULL,
|
|
`mechanism` tinyint unsigned NOT NULL,
|
|
`single_factor` tinyint unsigned NOT NULL DEFAULT '0',
|
|
`selector` varchar(24) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`expires_at` int unsigned DEFAULT NULL,
|
|
PRIMARY KEY (`id`),
|
|
KEY `user_id_mechanism` (`user_id`,`mechanism`),
|
|
KEY `selector_user_id` (`selector`,`user_id`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_remembered` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`user` int unsigned NOT NULL,
|
|
`selector` varchar(24) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`expires` int unsigned NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `selector` (`selector`),
|
|
KEY `user` (`user`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_resets` (
|
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
`user` int unsigned NOT NULL,
|
|
`selector` varchar(20) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`expires` int unsigned NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `selector` (`selector`),
|
|
KEY `user_expires` (`user`,`expires`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE `users_throttling` (
|
|
`bucket` varchar(44) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
|
|
`tokens` float NOT NULL,
|
|
`replenished_at` int unsigned NOT NULL,
|
|
`expires_at` int unsigned NOT NULL,
|
|
PRIMARY KEY (`bucket`),
|
|
KEY `expires_at` (`expires_at`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|