ALTER TABLE `GmTeam` ADD INDEX ( `TimeFrom` ) ;
ALTER TABLE `GmTeam` ADD INDEX ( `TimeTo` ) ;
ALTER TABLE `GmTeam` ADD INDEX ( `RealmId` ) ;

DROP TABLE `achievement` ,
`chyby` ,
`diskuze` ,
`export_list` ,
`uzivatele` ;

CREATE TABLE IF NOT EXISTS `Realm` (
  `Id` int(11) NOT NULL auto_increment,
  `Host` int(11) NOT NULL,
  `Logon` int(11) NOT NULL,
  `DatabaseHost` varchar(255) NOT NULL,
  `DatabaseUser` varchar(255) NOT NULL,
  `DatabasePassword` varchar(255) NOT NULL,
  `DatabaseCharacters` varchar(255) NOT NULL,
  `DatabaseMangos` varchar(255) NOT NULL,
  `DatabaseScriptDev2` varchar(255) NOT NULL,
  `MaxOnlinePlayers` int(11) NOT NULL,
  `Rate` int(11) NOT NULL,
  `Type` varchar(255) NOT NULL,
  `Name` varchar(255) NOT NULL,
  `Description` text NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

CREATE TABLE IF NOT EXISTS `Logon` (
  `Id` int(11) NOT NULL auto_increment,
  `Host` int(11) NOT NULL,
  `DatabaseUser` varchar(255) NOT NULL,
  `DatabasePassword` varchar(255) NOT NULL,
  `DatabaseHost` varchar(255) NOT NULL,
  `DatabaseRealmd` varchar(255) NOT NULL,
  `ClientVersion` varchar(255) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;


CREATE TABLE IF NOT EXISTS `Host` (
  `Id` int(11) NOT NULL auto_increment,
  `OS` varchar(255) NOT NULL,
  `CPU` varchar(255) NOT NULL,
  `Memory` varchar(255) NOT NULL,
  `HDD` varchar(255) NOT NULL,
  `Internet` varchar(255) NOT NULL,
  `Address` varchar(255) NOT NULL,
  `Statistic` varchar(255) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

ALTER TABLE `Logon` ADD INDEX ( `Host` ) ;
ALTER TABLE `Logon` ADD FOREIGN KEY ( `Host` ) REFERENCES `Host` (`Id`);

ALTER TABLE `Realm` ADD INDEX ( `Host` ) ;
ALTER TABLE `Realm` ADD INDEX ( `Logon` ) ;

ALTER TABLE `Realm` ADD FOREIGN KEY ( `Host` ) REFERENCES `Host` (`Id`);
ALTER TABLE `Realm` ADD FOREIGN KEY ( `Logon` ) REFERENCES `Logon` (`Id`);

ALTER TABLE `Article` ADD INDEX ( `Time` ) ;

ALTER TABLE `Realm` ADD `Online` INT NOT NULL DEFAULT '0';
ALTER TABLE `Logon` ADD `Port` INT NOT NULL ;

ALTER TABLE `articles` CHANGE `id` `Id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
CHANGE `title` `Title` TEXT CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL ,
CHANGE `autor` `Author` TEXT CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL ,
CHANGE `category` `Category` INT( 11 ) NOT NULL DEFAULT '0',
CHANGE `text` `Content` TEXT CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL ,
CHANGE `date` `Time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00';

RENAME TABLE `articles`  TO `Article` ;
ALTER TABLE `Article`  ENGINE = InnoDB;

ALTER TABLE `Article` ADD INDEX ( `Category` ) ;

CREATE TABLE IF NOT EXISTS `ArticleCategory` (
  `Id` int(11) NOT NULL auto_increment,
  `Name` varchar(255) NOT NULL,
  PRIMARY KEY  (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

INSERT INTO `ArticleCategory` (`Id`, `Name`) VALUES
(1, 'Server novinky'),
(2, 'GM novinky'),
(3, 'In-game novinky'),
(4, 'Články');

ALTER TABLE `Article` ADD FOREIGN KEY ( `Category` ) REFERENCES `ArticleCategory` (`Id`);

