-
Notifications
You must be signed in to change notification settings - Fork 2
/
schema.sql
107 lines (90 loc) · 2.87 KB
/
schema.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
--
-- Table structure for table `ci_sessions`
--
CREATE TABLE ci_sessions
(
session_id varchar(40) NOT NULL,
ip_address varchar(16) NOT NULL DEFAULT '0',
user_agent varchar(150) NOT NULL,
last_activity integer NOT NULL DEFAULT 0,
user_data text NOT NULL,
CONSTRAINT ci_session_pkey PRIMARY KEY (session_id)
);
-- --------------------------------------------------------
--
-- Table structure for table `login_attempts`
--
--
-- create sequence for login attempts table
--
CREATE SEQUENCE login_attempts_seq;
CREATE TABLE login_attempts
(
id integer NOT NULL DEFAULT NEXTVAL('login_attempts_seq'),
ip_address varchar(16) NOT NULL,
login varchar(50) NOT NULL,
time timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT login_attempts_pkey PRIMARY KEY (id)
);
-- --------------------------------------------------------
--
-- Table structure for table `user_autologin`
--
CREATE TABLE user_autologin
(
key_id varchar(32) NOT NULL,
user_id integer NOT NULL,
user_agent varchar(150) NOT NULL,
last_ip varchar(40) NOT NULL,
last_login timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT user_autologin_pkey PRIMARY KEY (key_id, user_id)
);
-- --------------------------------------------------------
--
-- Table structure for table `user_profiles`
--
--
-- Create sequence for user profiles table
--
CREATE SEQUENCE user_profiles_seq;
CREATE TABLE user_profiles
(
id integer NOT NULL DEFAULT NEXTVAL('user_profiles_seq'),
user_id integer NOT NULL,
country varchar(20) DEFAULT NULL,
website varchar(255) DEFAULT NULL,
profile_image varchar(200) DEFAULT 'default_profile_image.png',
CONSTRAINT user_profiles_pkey PRIMARY KEY (id)
);
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
--
-- create sequence for user table
--
CREATE SEQUENCE users_seq;
CREATE TABLE users
(
id integer NOT NULL DEFAULT NEXTVAL('users_seq'),
username varchar(50) NOT NULL,
password varchar(255) NOT NULL,
email varchar(100) NOT NULL,
activated integer NOT NULL DEFAULT 1,
banned integer NOT NULL DEFAULT 0,
ban_reason varchar(255) DEFAULT NULL,
new_password_key varchar(50) DEFAULT NULL,
new_password_requested timestamp without time zone DEFAULT NULL,
new_email varchar(100) DEFAULT NULL,
new_email_key varchar(50) DEFAULT NULL,
last_ip varchar(40) NOT NULL,
last_login timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT users_pkey PRIMARY KEY (id)
);
TRUNCATE TABLE ci_sessions;
TRUNCATE TABLE login_attempts;
TRUNCATE TABLE user_autologin;
TRUNCATE TABLE user_profiles;
TRUNCATE TABLE users;