root/veekun/trunk/script/base.sql @ 406

Revision 406, 7.6 KB (checked in by eevee, 22 months ago)

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Line 
1/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
2/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
3/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
4/*!40101 SET NAMES utf8 */;
5/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
6/*!40103 SET TIME_ZONE='+00:00' */;
7/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
8/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
9/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
10/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
11
12--
13-- Table structure for table `edits`
14--
15
16DROP TABLE IF EXISTS edits;
17CREATE TABLE edits (
18  id int(10) unsigned NOT NULL auto_increment,
19  post_id int(10) unsigned NOT NULL default '0',
20  user_id int(10) unsigned NOT NULL default '0',
21  `time` int(10) unsigned NOT NULL default '0',
22  old_content text NOT NULL,
23  PRIMARY KEY  (id),
24  KEY POSTID USING BTREE (post_id)
25) ENGINE=MyISAM DEFAULT CHARSET=latin1;
26
27--
28-- Table structure for table `error_log`
29--
30
31DROP TABLE IF EXISTS error_log;
32CREATE TABLE error_log (
33  id int(10) unsigned NOT NULL auto_increment,
34  `time` int(10) unsigned NOT NULL default '0',
35  user_id int(10) unsigned NOT NULL default '0',
36  ip int(10) unsigned NOT NULL default '0',
37  path tinytext NOT NULL,
38  method enum('POST','GET') default NULL,
39  `query` text NOT NULL,
40  error text NOT NULL,
41  PRIMARY KEY  (id)
42) ENGINE=MyISAM DEFAULT CHARSET=utf8;
43
44--
45-- Table structure for table `forums`
46--
47
48DROP TABLE IF EXISTS forums;
49CREATE TABLE forums (
50  id int(10) unsigned NOT NULL auto_increment,
51  `name` varchar(80) NOT NULL default 'Untitled Forum',
52  last_post_id int(10) unsigned default NULL,
53  thread_count int(10) unsigned NOT NULL default '0',
54  post_count int(10) unsigned NOT NULL default '0',
55  flags set('header') NOT NULL,
56  accessibility enum('normal','locked','archive','hidden') NOT NULL default 'normal',
57  description varchar(255) NOT NULL,
58  PRIMARY KEY  (id)
59) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
60
61--
62-- Table structure for table `group_permissions`
63--
64
65DROP TABLE IF EXISTS group_permissions;
66CREATE TABLE group_permissions (
67  group_id int(10) unsigned NOT NULL default '0',
68  permission varchar(64) NOT NULL default '',
69  scope varchar(64) NOT NULL default '',
70  polarity enum('allow','deny') default NULL,
71  PRIMARY KEY  USING BTREE (group_id,permission,scope)
72) ENGINE=MyISAM DEFAULT CHARSET=latin1;
73
74--
75-- Table structure for table `groups`
76--
77
78DROP TABLE IF EXISTS groups;
79CREATE TABLE groups (
80  id int(10) unsigned NOT NULL auto_increment,
81  icon tinytext NOT NULL,
82  `name` tinytext NOT NULL,
83  UNIQUE KEY id (id)
84) ENGINE=InnoDB DEFAULT CHARSET=utf8;
85
86--
87-- Table structure for table `messages`
88--
89
90DROP TABLE IF EXISTS messages;
91CREATE TABLE messages (
92  id int(10) unsigned NOT NULL auto_increment,
93  from_user_id int(10) unsigned NOT NULL default '0',
94  to_user_id int(10) unsigned NOT NULL default '0',
95  `time` int(10) unsigned NOT NULL default '0',
96  `subject` tinytext NOT NULL,
97  message text NOT NULL,
98  PRIMARY KEY  (id)
99) ENGINE=MyISAM DEFAULT CHARSET=latin1;
100
101--
102-- Table structure for table `posts`
103--
104
105DROP TABLE IF EXISTS posts;
106CREATE TABLE posts (
107  id int(10) unsigned NOT NULL auto_increment,
108  thread_id int(10) unsigned NOT NULL default '0',
109  user_id int(10) unsigned NOT NULL default '0',
110  flags set('deleted') NOT NULL default '',
111  `time` int(10) unsigned NOT NULL default '0',
112  format enum('bbcode','raw','html') NOT NULL default 'raw',
113  content text NOT NULL,
114  last_edit_id int(10) unsigned NOT NULL default '0',
115  PRIMARY KEY  (id),
116  KEY THREAD USING BTREE (thread_id),
117  KEY `USER` USING BTREE (user_id)
118) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED;
119
120--
121-- Table structure for table `sessions`
122--
123
124DROP TABLE IF EXISTS sessions;
125CREATE TABLE sessions (
126  id varchar(72) NOT NULL default '',
127  user_id int(10) unsigned NOT NULL default '0',
128  time_expires int(10) unsigned default NULL,
129  `data` text,
130  PRIMARY KEY  USING BTREE (id),
131  KEY USER_ID USING BTREE (user_id)
132) ENGINE=MyISAM DEFAULT CHARSET=latin1;
133
134--
135-- Table structure for table `shoutbox`
136--
137
138DROP TABLE IF EXISTS shoutbox;
139CREATE TABLE shoutbox (
140  id int(10) unsigned NOT NULL auto_increment,
141  `name` varchar(24) NOT NULL default 'Anonymous',
142  user_id int(10) unsigned default NULL,
143  ip int(10) unsigned NOT NULL default '0',
144  `time` int(10) unsigned NOT NULL default '0',
145  content text NOT NULL,
146  PRIMARY KEY  (id)
147) ENGINE=MyISAM DEFAULT CHARSET=latin1;
148
149--
150-- Table structure for table `threads`
151--
152
153DROP TABLE IF EXISTS threads;
154CREATE TABLE threads (
155  id int(10) unsigned NOT NULL auto_increment,
156  forum_id int(10) unsigned NOT NULL default '0',
157  `subject` varchar(48) NOT NULL default 'Untitled Thread',
158  blurb varchar(96) NOT NULL default '',
159  first_post_id int(10) unsigned NOT NULL,
160  last_post_id int(10) unsigned NOT NULL,
161  last_post_time int(10) unsigned NOT NULL default '0',
162  post_count int(10) unsigned NOT NULL default '0',
163  view_count int(10) unsigned NOT NULL default '0',
164  flags set('locked','sticky','announcement','deleted') NOT NULL default '',
165  PRIMARY KEY  (id),
166  KEY FORUMID USING BTREE (forum_id)
167) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
168
169--
170-- Table structure for table `thread_views`
171--
172
173DROP TABLE IF EXISTS thread_views;
174CREATE TABLE thread_views (
175  thread_id int(10) unsigned NOT NULL,
176  user_id int(10) unsigned NOT NULL,
177  last_viewed int(10) unsigned NOT NULL,
178  PRIMARY KEY  (thread_id,user_id)
179) ENGINE=InnoDB DEFAULT CHARSET=utf8;
180
181--
182-- Table structure for table `user_groups`
183--
184
185DROP TABLE IF EXISTS user_groups;
186CREATE TABLE user_groups (
187  user_id int(10) unsigned NOT NULL default '0',
188  group_id tinyint(3) unsigned NOT NULL default '0',
189  priority tinyint(3) unsigned NOT NULL default '0',
190  PRIMARY KEY  USING BTREE (user_id,group_id,priority),
191  KEY user_id USING BTREE (user_id),
192  KEY group_id USING BTREE (group_id)
193) ENGINE=MyISAM DEFAULT CHARSET=latin1;
194
195--
196-- Table structure for table `users`
197--
198
199DROP TABLE IF EXISTS users;
200CREATE TABLE users (
201  id int(10) unsigned NOT NULL auto_increment,
202  `name` varchar(20) NOT NULL default '',
203  `password` varchar(40) NOT NULL,
204  time_joined int(10) unsigned NOT NULL default '0',
205  time_active int(10) unsigned NOT NULL default '0',
206  thread_view_cutoff int(10) unsigned NOT NULL,
207  post_count int(10) unsigned NOT NULL default '0',
208  flags set('lockedsig','lockedavatar','lockedtitle') NOT NULL default '',
209  news_pic varchar(64) default NULL,
210  avatar varchar(64) default NULL,
211  contact_aim varchar(32) NOT NULL default '',
212  contact_icq varchar(32) NOT NULL default '',
213  contact_msn varchar(32) NOT NULL default '',
214  contact_yim varchar(32) NOT NULL default '',
215  contact_lj varchar(32) NOT NULL default '',
216  contact_homepage varchar(96) NOT NULL default '',
217  contact_email varchar(32) NOT NULL default '',
218  pm_icon enum('bead','bellossom','dream','duskull','eatmail','gorgeous','letter','magnemite','pika','retro','slakoth','vee','wailmer','wingull','zigzagoon') NOT NULL default 'letter',
219  custom_title varchar(32) NOT NULL,
220  signature text NOT NULL,
221  is_dumb tinyint(1) NOT NULL default '0',
222  PRIMARY KEY  (id),
223  UNIQUE KEY `NAME` (`name`)
224) ENGINE=MyISAM DEFAULT CHARSET=latin1;
225/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
226
227/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
228/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
229/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
230/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
231/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
232/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
233/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
234
Note: See TracBrowser for help on using the browser.