﻿ALTER TABLE [dnt_forums] ADD [allowpostspecial] integer default 0;
ALTER TABLE [dnt_forums] ADD [allowspecialonly] integer default 0;
ALTER TABLE [dnt_forums] ADD [allowtag] integer default 0;


UPDATE  [dnt_forums] SET [allowpostspecial]=0,[allowspecialonly]=0,[allowtag]=0;

ALTER TABLE [dnt_usergroups] ADD [allowdebate] integer default 0 not null;
ALTER TABLE [dnt_usergroups] ADD [allowbonus] integer default 0 not null;
ALTER TABLE [dnt_usergroups] ADD [minbonusprice] integer default 0 not null;
ALTER TABLE [dnt_usergroups] ADD [maxbonusprice] integer default 0 not null;
ALTER TABLE [dnt_usergroups] ADD [allowtrade] integer default 0 not null;
ALTER TABLE [dnt_usergroups] ADD [allowdiggs] integer default 0 not null; 
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=100,[allowtrade]=1,[allowdiggs]=1 where groupid=1;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=90,[allowtrade]=1,[allowdiggs]=1 where groupid=2;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=80,[allowtrade]=1,[allowdiggs]=1 where groupid=3;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=1 where groupid=4;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=0 where groupid=5;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=0 where groupid=6;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=0 where groupid=7;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=0 where groupid=8;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=0 where groupid=9;
UPDATE  [dnt_usergroups] SET [allowdebate]=0,[allowbonus]=0,[minbonusprice]=0,[maxbonusprice]=0,[allowtrade]=0,[allowdiggs]=1 where groupid=10;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=20,[allowtrade]=0,[allowdiggs]=1 where groupid=11;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=30,[allowtrade]=1,[allowdiggs]=1 where groupid=12;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=50,[allowtrade]=1,[allowdiggs]=1 where groupid=13;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=60,[allowtrade]=1,[allowdiggs]=1 where groupid=14;
UPDATE  [dnt_usergroups] SET [allowdebate]=1,[allowbonus]=1,[minbonusprice]=1,[maxbonusprice]=70,[allowtrade]=1,[allowdiggs]=1 where groupid=15;

ALTER TABLE [dnt_statistics] ADD [yesterdayposts] integer default 0;
ALTER TABLE [dnt_statistics] ADD [highestposts] integer default 0;
ALTER TABLE [dnt_statistics] ADD [highestpostsdate] char (10) DEFAULT '';
UPDATE  [dnt_statistics] SET [yesterdayposts]=0,[highestposts]=0,[highestpostsdate]='';

ALTER TABLE [dnt_creditslog] ALTER COLUMN [sendcredits] integer default 0;
ALTER TABLE [dnt_creditslog] ALTER COLUMN [receivecredits] integer default 0;
ALTER TABLE [dnt_creditslog] ALTER COLUMN [send] float default 0.0;
ALTER TABLE [dnt_creditslog] ALTER COLUMN [receive] float integer default 0.0;
UPDATE  [dnt_creditslog] SET [sendcredits]=0,[receivecredits]=0,[send]=0.0,[receive]=0.0;

ALTER TABLE [dnt_help] ALTER COLUMN [orderby] integer default 0;
UPDATE  [dnt_help] SET [orderby]=0;

ALTER TABLE [dnt_help] ADD [orderby] integer default 0;
ALTER TABLE [dnt_paymentlog] ADD [buydate] datetime default Now();
ALTER TABLE [dnt_ratelog] ADD [postdatetime] datetime default Now();
UPDATE [dnt_forums] SET [colcount] = 1;


ALTER TABLE [dnt_topics] ADD [special] integer default 0;
UPDATE [dnt_topics] SET [special] = 0;
UPDATE [dnt_topics] SET [special] = [poll];
ALTER TABLE [dnt_topics] DROP COLUMN [poll];


ALTER TABLE [dnt_forums] ADD [istrade] integer default 0;
UPDATE [dnt_forums] SET [istrade] = 0;
ALTER TABLE [dnt_forums] DROP COLUMN [allowtrade];



drop table [dnt_online]
;
CREATE TABLE [dnt_online] (
	[olid] autoincrement(1, 1),
	[userid] integer default 0,
	[ip] varchar(15) ,
	[username] nvarchar(20) ,
	[nickname] nvarchar(20) ,
	[password] char(32) ,
	[groupid] integer default 0,
	[olimg] varchar(80) ,
	[adminid] integer default 0,
	[invisible] integer default 0,
	[action] integer default 0,
	[lastactivity] integer default 0,
	[lastposttime] datetime ,
	[lastpostpmtime] datetime ,
	[lastsearchtime] datetime ,
	[lastupdatetime] datetime ,
	[forumid] integer default 0,
	[forumname] nvarchar(50) ,
	[titleid] integer default 0,
	[title] nvarchar(80) ,
	[verifycode] varchar(10) 
)
;

CREATE Unique INDEX [PrimaryKey] on [dnt_online]([olid] ) with Primary
;


drop table [dnt_tags];
CREATE TABLE [dnt_tags] (
	[tagid] autoincrement(1, 1) ,
	[tagname] varchar (10) ,
	[userid] integer default 0,
	[postdatetime] datetime ,
	[orderid] integer default 0,
	[color] char (6) ,
	[count] integer default 0,
	[fcount] integer default 0,
	[pcount] integer default 0,
	[scount] integer default 0,
	[vcount] integer default 0,
	[gcount] integer default 0
) 
;
CREATE Unique INDEX [PrimaryKey] on [dnt_tags]([tagid] ) with Primary
;

drop table [dnt_bonuslog];
CREATE TABLE [dnt_bonuslog] (
	[tid] integer default 0,
	[authorid] integer default 0,
	[answerid] integer default 0,
	[answername] nchar (20) ,
	[pid] integer default 0,
	[dateline] datetime ,
	[bonus] integer default 0,
	[extid] integer default 0,
	[isbest] integer default 0
)
;
CREATE Unique INDEX [PrimaryKey] on [dnt_bonuslog]([tid] ) with Primary
;

drop table [dnt_debatediggs];
CREATE TABLE [dnt_debatediggs] (
	[tid] integer default 0,
	[pid] integer default 0,
	[digger] nchar (20) ,
	[diggerid] integer default 0,
	[diggerip] nchar (15) ,
	[diggdatetime] datetime 
)
;


drop table [dnt_debates];
CREATE TABLE [dnt_debates] (
	[tid] integer default 0,
	[positiveopinion] nvarchar(200) ,
	[negativeopinion] nvarchar(200) ,
	[terminaltime] datetime ,
	[positivediggs] integer default 0,
	[negativediggs] integer default 0
)
;

drop table [dnt_myattachments];
CREATE TABLE [dnt_myattachments] (
	[aid] integer default 0,
	[uid] integer default 0,
	[attachment] nchar (100) ,
	[description] nchar (100) ,
	[postdatetime] datetime ,
	[downloads] integer default 0,
	[filename] nchar (100) ,
	[pid] integer default 0,
	[tid] integer default 0,
	[extname] nvarchar(50) default '' 
)
;


drop table [dnt_onlinetime];
CREATE TABLE [dnt_onlinetime] (
	[uid] integer default 0,
	[thismonth] integer default 0,
	[total] integer default 0,
	[lastupdate] datetime 
)
;

drop table [dnt_onlinetime]
;
CREATE TABLE [dnt_onlinetime] (
	[uid] integer default 0,
	[thismonth] integer default 0,
	[total] integer default 0,
	[lastupdate] datetime default Now()
)
;
CREATE Unique INDEX [PrimaryKey] on [dnt_onlinetime]([uid] ) with Primary
;

drop table [dnt_postdebatefields]
;
CREATE TABLE [dnt_postdebatefields] (
	[tid] integer default 0,
	[pid] integer default 0,
	[opinion] integer default 0,
	[diggs] integer default 0
)
;

CREATE TABLE [dnt_scheduledevents] (
	[scheduleID] autoincrement(1, 1) ,
	[key] varchar(50) ,
	[lastexecuted] datetime ,
	[servername] varchar(100) 
)
;

drop table [dnt_stats];
CREATE TABLE [dnt_stats] (
	[type] char (10) ,
 	[variable] char (20) ,
	[count] integer default 0
)
;

drop table [dnt_statvars];
CREATE TABLE [dnt_statvars] (
	[type] char (20) ,
	[variable] char (20) ,
	[value] text
)
;

drop table [dnt_topictags];
CREATE TABLE [dnt_topictags] (
	[tagid] integer default 0,
	[tid] integer default 0
)
;