appidea-restapi/scheme.sql

87 lines
2.4 KiB
SQL

--
-- Database: `app-idea`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` CHAR(32) NOT NULL,
`hashtag` varchar(6) NOT NULL,
`name` varchar(30) NOT NULL,
`email` varchar(255) NOT NULL,
`password` char(60) NOT NULL,
`rank` tinyint(4) DEFAULT 0,
`avatar_url` varchar(255) DEFAULT NULL,
`location` varchar(20) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`language` tinyint(4) DEFAULT 0,
`cash` int(11) DEFAULT 0,
`posts` int(11) DEFAULT 0,
`followers` int(11) DEFAULT 0,
`following` int(11) DEFAULT 0,
`last_login` datetime DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `pictures`
--
CREATE TABLE `pictures` (
`user_id` CHAR(36) NOT NULL,
`picture_id` int(11) NOT NULL,
`likes` int(11) DEFAULT 0,
`dislikes` int(11) DEFAULT 0,
`location` varchar(20) NOT NULL,
`description` varchar(250) DEFAULT NULL,
`created` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `sessions`
--
CREATE TABLE `sessions` (
`user_id` CHAR(32) NOT NULL,
`session_id` CHAR(32) NOT NULL,
`ip` varchar(32) NOT NULL,
`user_agent` varchar(32) NOT NULL,
`last_login` datetime NOT NULL,
`expires` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------
--
-- Table structure for table `server_settings`
--
CREATE TABLE `server_settings` (
`name` varchar(50) NOT NULL,
`value` varchar(50) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `server_settings`
--
INSERT INTO `server_settings` (`name`, `value`, `created_at`, `updated_at`) VALUES
('expired_time', '72', '2021-05-28 19:18:12', NULL),
('username_min_len', '3', '2021-06-06 17:27:38', NULL),
('username_max_len', '30', '2021-06-06 17:40:39', NULL),
('email_min_len', '3', '2021-06-06 17:41:01', NULL),
('email_max_len', '255', '2021-06-06 17:41:31', NULL),
('password_min_len', '6', '2021-06-06 17:41:50', NULL),
('password_max_len', '250', '2021-06-06 17:42:01', NULL);
COMMIT;