-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatabase.sql
112 lines (97 loc) · 4.35 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-- Adminer 4.6.3 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `addresses`;
CREATE TABLE `addresses` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `created_at` (`created_at`),
KEY `user_id` (`user_id`),
FULLTEXT KEY `address` (`address`),
CONSTRAINT `addresses_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `emails`;
CREATE TABLE `emails` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`email` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `user_id` (`user_id`),
KEY `created_at` (`created_at`),
CONSTRAINT `emails_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `files`;
CREATE TABLE `files` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`file_type` varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`file_size` bigint(20) NOT NULL,
`sha1_checksum` char(40) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`md5_checksum` char(32) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`description` text NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `sha1_checksum` (`sha1_checksum`),
KEY `md5_checksum` (`md5_checksum`),
KEY `created_at` (`created_at`),
KEY `updated_at` (`updated_at`),
KEY `file_type` (`file_type`),
FULLTEXT KEY `description` (`description`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `phones`;
CREATE TABLE `phones` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`phone` varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `phone` (`phone`),
KEY `user_id` (`user_id`),
KEY `created_at` (`created_at`),
CONSTRAINT `phones_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`first_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`last_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`username` varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL,
`gender` enum('m','f') CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`password` text CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`primary_email` bigint(20) DEFAULT NULL,
`primary_phone` bigint(20) DEFAULT NULL,
`primary_address` bigint(20) DEFAULT NULL,
`registered_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
KEY `first_name` (`first_name`),
KEY `last_name` (`last_name`),
KEY `registered_at` (`registered_at`),
KEY `updated_at` (`updated_at`),
KEY `primary_email` (`primary_email`),
KEY `primary_address` (`primary_address`),
KEY `primary_phone` (`primary_phone`),
CONSTRAINT `users_ibfk_4` FOREIGN KEY (`primary_email`) REFERENCES `emails` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `users_ibfk_5` FOREIGN KEY (`primary_address`) REFERENCES `addresses` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT `users_ibfk_6` FOREIGN KEY (`primary_phone`) REFERENCES `phones` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `user_keys`;
CREATE TABLE `user_keys` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`ukey` text CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL,
`created_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `user_keys_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 2018-12-31 16:28:02