
drop table bm_user IF EXISTS;
create table bm_user(
	user_id int GENERATED BY DEFAULT AS IDENTITY not null,
	user_name varchar(50) default '' not null ,
	user_nickname varchar(50) null,
	user_password varchar(50) default '' not null ,
	user_email varchar(75) default '' not null ,
	user_description varchar(500) null,
	user_imageurl varchar(100) null,
	user_created_on timestamp default CURRENT_TIMESTAMP NOT NULL ,
  	user_modified_on timestamp default CURRENT_TIMESTAMP NOT NULL ,
  	user_isadmin tinyint default 0 not null,
  	user_isvalid tinyint default 0 not null,
	primary key (user_id)
);

drop table bm_usermeta IF EXISTS;
create table bm_usermeta(
	usermeta_id int GENERATED BY DEFAULT AS IDENTITY not null,
	user_id int,
	usermeta_key varchar,
	usermeta_value varchar,
	usermeta_created_on timestamp default CURRENT_TIMESTAMP NOT NULL ,
	usermeta_modified_on timestamp default CURRENT_TIMESTAMP NOT NULL ,
	primary key(usermeta_id)
);

drop table bm_option IF EXISTS;
create table bm_option(
	option_id int GENERATED BY DEFAULT AS IDENTITY not null,
	option_name varchar(64) default '' NOT NULL,
	option_value varchar,
	option_description varchar(200),
	primary key(option_id)	
);

drop table bm_article IF EXISTS;
create table bm_article(
	article_id int GENERATED BY DEFAULT AS IDENTITY not null,
	article_title varchar(100) default '' not null,
	article_content varchar default '',
	article_excerpt varchar default '',
	article_status tinyint default 0 not null ,
	article_created_on timestamp default current_timestamp NOT NULL,
	article_modified_on timestamp default current_timestamp NOT NULL,
	article_allowcomment tinyint default 0 not null ,
	article_allowtrackback tinyint default 0 not null ,
	primary key (article_id)
);

drop table bm_tag IF EXISTS;
create table bm_tag(
	tag_id int GENERATED BY DEFAULT AS IDENTITY not null,
	tag_title varchar(100) default '' not null,
	tag_created_on timestamp default current_timestamp NOT NULL,
	tag_modified_on timestamp default current_timestamp NOT NULL,
	primary key (tag_id)
)

drop table bm_article2tag IF EXISTS;
create table bm_article2tag(
	article2tag_id int GENERATED BY DEFAULT AS IDENTITY not null,
	article2tag_article_id int not null,
	article2tag_tag_id int not null,
	article2tag_created_on timestamp default current_timestamp NOT NULL,
	article2tag_modified_on timestamp default current_timestamp NOT NULL,
	primary key (article2tag_id)
)

drop table bm_comment IF EXISTS;
create table bm_comment(
	comment_id int GENERATED BY DEFAULT AS IDENTITY not null,
	comment_object_id int not null,
	comment_author varchar(100),
	comment_email varchar(75),
	comment_url varchar(100),
	comment_content varchar(500),
	comment_status tinyint default 0 not null,
	comment_time timestamp default current_timestamp NOT NULL,
	comment_notified tinyint default 0 not null,
	comment_ip varchar(50) null,
	primary key (comment_id)
)

drop table bm_trackback IF EXISTS;
create table bm_trackback(
	trackback_id int GENERATED BY DEFAULT AS IDENTITY not null,
	trackback_object_id int not null,
	trackback_title varchar(255) default NULL,
  	trackback_url varchar(255) default '' NOT NULL,
  	trackback_excerpt varchar(500) default null,
  	trackback_blog_name varchar(255) default NULL,
  	trackback_notified tinyint default 0 not null,
  	trackback_time timestamp default current_timestamp NOT NULL,
  	trackback_status tinyint default 0 not null,
  	trackback_ip varchar(50) null,
  	PRIMARY KEY  (trackback_id)
)

drop table bm_linkscategory if exists;
create table bm_linkscategory(
	linkscategory_id int GENERATED BY DEFAULT AS IDENTITY not null,
	linkscategory_name varchar(100) default '' not null,
	linkscategory_sortby tinyint default 0 not null,
	linkscategory_sortdesc tinyint default 0 not null,
	linkscategory_visible tinyint default 1 not null,
	linkscategory_created_on timestamp default current_timestamp NOT NULL,
	linkscategory_modified_on timestamp default current_timestamp NOT NULL,
	primary key (linkscategory_id)
)

drop table bm_link if exists;
create table bm_link(
	link_id int GENERATED BY DEFAULT AS IDENTITY not null,
	link_url varchar(200) not null,
	link_title varchar(100) not null,
	link_description varchar(1000) null,
	link_linkscategory_id int,
	link_image varchar(200) null,
	link_rss varchar(200) null,
	link_visible tinyint default 1 not null,
	link_created_on timestamp default current_timestamp NOT NULL,
	link_modified_on timestamp default current_timestamp NOT NULL,
	primary key (link_id)
)

drop table bm_page if exists;
create table bm_page(
	page_id int GENERATED BY DEFAULT AS IDENTITY not null,
	page_key varchar(20),
	page_title varchar(100) default '' not null,
	page_content varchar(9000) ,	
	page_status tinyint default 0 not null,
	page_parentid int default 0 not NULL,
	page_order int default 0 not null,
	page_created_on timestamp default current_timestamp NOT NULL,
	page_modified_on timestamp default current_timestamp NOT NULL,
	page_displayinnav tinyint default 0 not null,
	primary key (page_id)
)

drop table bm_message if exists;
create table bm_message(
	message_id int GENERATED BY DEFAULT AS IDENTITY not null,
	message_author varchar(100), 
	message_email varchar(75),
	message_url varchar(100),
	message_content varchar(500),
	message_status tinyint default 0 not null,
	message_time timestamp default current_timestamp NOT NULL,
	message_notified tinyint default 0 not null,
	message_ip varchar(50) null,
	primary key (message_id)
)

drop table bm_file if exists;
create table bm_file(
	file_id int GENERATED BY DEFAULT AS IDENTITY not null,
	file_name varchar(100) not null, 
	file_type varchar(30) not null,
	file_path varchar(200) not null,
	file_filepath varchar(200) not null,
	file_length bigint,
	file_time timestamp default current_timestamp NOT NULL,
	file_parentid INT default 0 not null,
	file_isdirectory tinyint default 0 not null,
	primary key (file_id)
)


delete from bm_option where 1=1;

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_page_length','10','');

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_editor_height','300','');

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_editor_mode','advanced','');

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_status','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_feed_length','10','');

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'article_feed_type','excerpt','');

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'comment_enabled','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'trackback_enabled','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'comment_must_be_approved','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'comment_filter','','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'comment_urls_limit','5','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'comment_spam','','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'theme_dir_name','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'page_default_status','1','')

insert into bm_option (option_id,option_name,option_value,option_description) 
values (null, 'file_page_length','20','')

insert into bm_page (page_id,page_key,page_title,page_content,page_status,page_parentid,page_order,page_created_on,page_modified_on,page_displayinnav)
values (null,'about','关于','页面内容为空',1,-1,0,curtime(),curtime(),1)

insert into bm_linkscategory (linkscategory_id,linkscategory_name,linkscategory_sortby,linkscategory_sortdesc,linkscategory_visible,linkscategory_created_on,linkscategory_modified_on)
values (null,'友情链接',1,0,1,curtime(),curtime())

insert into bm_link (link_id,link_url,link_title,link_description,link_linkscategory_id,link_image,link_rss,link_visible,link_created_on,link_modified_on)
values (null,'http://www.collin.cn','Collin','',0,null,'http://www.collin.cn/feeds/',1,curtime(),curtime())

insert into bm_link (link_id,link_url,link_title,link_description,link_linkscategory_id,link_image,link_rss,link_visible,link_created_on,link_modified_on)
values (null,'http://www.blogmethods.cn/blog/','BlogMethods','博客软件 BlogMethods 官方博客',0,null,'http://www.blogmethods.cn/blog/feeds/',1,curtime(),curtime())




