summaryrefslogtreecommitdiff
path: root/demos/blog/protected/Common/schema.sql
blob: 9c111f0cc1b7bc7878b0ef222949b1e6a3d0d543 (plain)
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
CREATE TABLE tblUsers (
  id			INTEGER NOT NULL PRIMARY KEY,
  name			VARCHAR(128) NOT NULL UNIQUE,
  full_name		VARCHAR(128) DEFAULT '',
  role          INTEGER NOT NULL DEFAULT 0, /* 0: user, 1: admin */
  passwd		VARCHAR(128) NOT NULL,
  vcode			VARCHAR(128) DEFAULT '',
  email		    VARCHAR(128) NOT NULL,
  reg_time		INTEGER NOT NULL,
  status		INTEGER NOT NULL DEFAULT 0, /* 0: normal, 1: disabled, 2: pending approval */
  website	    VARCHAR(128) DEFAULT ''
);

CREATE TABLE tblPosts (
  id			INTEGER NOT NULL PRIMARY KEY,
  author_id		INTEGER NOT NULL,
  create_time	INTEGER NOT NULL,
  modify_time	INTEGER DEFAULT 0,
  title			VARCHAR(256) NOT NULL,
  content		TEXT NOT NULL,
  status		INTEGER NOT NULL DEFAULT 0, /* 0: published, 1: draft, 2: pending approval */
  comment_count	INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE tblComments (
  id			INTEGER NOT NULL PRIMARY KEY,
  post_id		INTEGER NOT NULL,
  author_name	VARCHAR(64) NOT NULL,
  author_email	VARCHAR(128) NOT NULL,
  author_website VARCHAR(128) DEFAULT '',
  author_ip		CHAR(16) NOT NULL,
  create_time	INTEGER NOT NULL,
  status		INTEGER NOT NULL DEFAULT 0, /* 0: published, 1: pending approval */
  content		TEXT NOT NULL
);

CREATE TABLE tblCategories (
  id			INTEGER NOT NULL PRIMARY KEY,
  name			VARCHAR(128) NOT NULL UNIQUE,
  description	TEXT DEFAULT '',
  post_count	INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE tblAttachments (
  id			VARCHAR(128) NOT NULL PRIMARY KEY,
  post_id		INTEGER NOT NULL,
  create_time	INTEGER NOT NULL,
  file_name		VARCHAR(128) NOT NULL,
  file_size		INTEGER NOT NULL,
  mime_type		VARCHAR(32) NOT NULL DEFAULT 'text/html',
  download_count INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE tblPost2Category (
  post_id		INTEGER NOT NULL,
  category_id	INTEGER NOT NULL,
  PRIMARY KEY (post_id, category_id)
);

INSERT INTO tblUsers (id,name,full_name,role,status,passwd,email,reg_time,website)
	VALUES (1,'admin','Prado User',1,0,'4d688da592969d0a56b5accec3ce8554','admin@example.com',1148819681,'http://www.pradosoft.com');

INSERT INTO tblPosts (id,author_id,create_time,title,content,status)
	VALUES (1,1,1148819691,'Welcome to Prado Weblog','Congratulations! You have successfully installed Prado Blog -- a PRADO-driven weblog system. A default administrator account has been created. Please login with <b>admin/prado</b> and update your password as soon as possible.',0);

INSERT INTO tblCategories (name,description,post_count)
	VALUES ('Miscellaneous','This category holds posts on any topic.',1);

INSERT INTO tblCategories (name,description,post_count)
	VALUES ('PRADO','Topics related with the PRADO framework.',0);

INSERT INTO tblCategories (name,description,post_count)
	VALUES ('PHP','Topics related with PHP.',0);

INSERT INTO tblPost2Category (post_id,category_id)
	VALUES (1,1);