#
# HLstats Database Upgrade file
# -----------------------------
#
# To upgrade an existing HLstats 1.10 database to version 1.20, type:
#
#   mysql hlstats < upgrade_from_1.10.sql
#
#   THEN
#
#   mysql hlstats < gamesupport_xxxx.sql
#


#
# Remove old Teams table
#
DROP TABLE hlstats_Teams;


#
# Add new Teams table
#
CREATE TABLE hlstats_Teams (
  teamId int(10) unsigned NOT NULL auto_increment,
  game varchar(16) DEFAULT 'valve' NOT NULL,
  code varchar(32) DEFAULT '' NOT NULL,
  name varchar(64) DEFAULT '' NOT NULL,
  hidden enum('0', '1') DEFAULT '0' NOT NULL,
  PRIMARY KEY (teamId),
  UNIQUE gamecode (game,code)
);


#
# Add Roles Table
#
CREATE TABLE hlstats_Roles (
  roleId int(10) unsigned NOT NULL auto_increment,
  game varchar(16) DEFAULT 'valve' NOT NULL,
  code varchar(32) DEFAULT '' NOT NULL,
  name varchar(64) DEFAULT '' NOT NULL,
  hidden enum('0', '1') DEFAULT '0' NOT NULL,
  PRIMARY KEY (roleId),
  UNIQUE gamecode (game,code)
);


#
# Remove Teams in old format 
#
TRUNCATE hlstats_Teams;


#
# Add Weapon Body Color
#
INSERT INTO hlstats_Options VALUES ('table_wpnbgcolor','#000000');


#
# Empty Action, Awards, Games, and Weapons Tables
#
TRUNCATE hlstats_Actions;
TRUNCATE hlstats_Awards;
TRUNCATE hlstats_Games;
TRUNCATE hlstats_Weapons;
