-- 
-- Base de données: `phpcompet`
-- 

# 
# changes in DB version 16
# 

ALTER TABLE `teams` ADD `start` DATE NOT NULL, ADD `end` DATE NOT NULL, ADD `games` INT( 11 ) NOT NULL , ADD `minutes` INT( 11 ) NOT NULL, ADD `goals` INT( 11 ) NOT NULL, ADD `ycards` INT( 11 ) NOT NULL,
ADD `rcards` INT( 11 ) NOT NULL;
REPLACE INTO config (opt, value) VALUES 
('debug', '0'),
('activeclubs', '1'),
('activestadiums', '1'),
('activecompetitions', '1'),
('activeplayers', '1'),
('activereferees', '1'),
('activecalendar', '1');

REPLACE INTO seasons (id, season) VALUES ('18', '2007');

# 
# changes in DB version 82
# 

ALTER TABLE `clubs` ADD `id_president` VARCHAR( 11 ) NOT NULL AFTER `id_stadium` ;

ALTER TABLE `persons` ADD `license` VARCHAR( 255 ) NOT NULL AFTER `imgurl`,
ADD `contribution` BOOL NULL AFTER `license` ,
ADD `stop_mail` BOOL NULL AFTER `contribution` ,
ADD `email` VARCHAR( 255 ) NOT NULL AFTER `stop_mail` ,
ADD `website` VARCHAR( 255 ) NOT NULL AFTER `email` ,
ADD `address` VARCHAR( 255 ) NOT NULL AFTER `website` ,
ADD `tel1` VARCHAR( 255 ) NOT NULL AFTER `address` ,
ADD `tel2` VARCHAR( 255 ) NOT NULL AFTER `tel1` ;

REPLACE INTO config (opt, value) VALUES ('seasonfilterdefault', '18');

# 
# changes in DB version 83
# 

ALTER TABLE `paramcompetitions` ADD `dom_vic_ext` INT( 11 ) NOT NULL AFTER `ext_def` ,
ADD `dom_nul_ext` INT( 11 ) NOT NULL AFTER `dom_vic_ext` ,
ADD `dom_def_ext` INT( 11 ) NOT NULL AFTER `dom_nul_ext` ,
ADD `ext_vic_ext` INT( 11 ) NOT NULL AFTER `dom_def_ext` ,
ADD `ext_nul_ext` INT( 11 ) NOT NULL AFTER `ext_vic_ext` ,
ADD `ext_def_ext` INT( 11 ) NOT NULL AFTER `ext_nul_ext` ,
ADD `period` SMALLINT( 5 ) NOT NULL AFTER `ext_def_ext` ,
ADD `period_time` INT( 11 ) NOT NULL AFTER `period` ,
ADD `extension` SMALLINT( 5 ) NOT NULL AFTER `period_time` ,
ADD `extension_time` INT( 11 ) NOT NULL AFTER `extension`,
ADD `taborder` CHAR( 50 ) NULL AFTER `ar`;

ALTER TABLE `competitions` ADD `oneyear` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `range`;

CREATE TABLE `lineup` (
`id` INT( 11 ) NOT NULL auto_increment,
`id_match` INT( 11 ) NOT NULL ,
`id_club` INT( 11 ) NOT NULL ,
`id_person` INT( 11 ) NOT NULL ,
`type` SMALLINT( 2 ) NOT NULL ,
`captain` SMALLINT( 2 ) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `subs` (
`id` INT( 11 ) NOT NULL auto_increment,
`id_match` INT( 11 ) NOT NULL ,
`id_club` INT( 11 ) NOT NULL ,
`id_person_in` INT( 11 ) NOT NULL ,
`id_person_out` INT( 11 ) NOT NULL ,
`subs_min` INT( 5 ) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


# 
# changes in DB version 84
# 

CREATE TABLE `caracs` (
`id` INT( 11 ) NOT NULL auto_increment PRIMARY KEY ,
`shortname` VARCHAR( 255 ) NOT NULL ,
`lib_key` CHAR( 10 ) NOT NULL ,
`type` SMALLINT( 3 ) NOT NULL ,
`genre` SMALLINT( 3 ) NOT NULL ,
`rank` SMALLINT( 3 ) NOT NULL,
`perm` SMALLINT( 5 ) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=latin1;

CREATE TABLE `values` (
`id_carac` INT( 11 ) NOT NULL ,
`id_item` INT( 11 ) NOT NULL ,
`value` VARCHAR( 255 ) NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=latin1;

ALTER TABLE `matchs` ADD `validation` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `temperature`;
UPDATE `matchs` SET `validation` =1 WHERE (DATEDIFF( date_day, NOW( ) ) < 0 OR TIMEDIFF( date_day, NOW( ) ) < 0);
REPLACE INTO config (opt, value) VALUES ('automatchvalidation', '1');

ALTER TABLE `news` ADD `owner_id` VARCHAR( 11 ) NOT NULL default '0' AFTER `newsfrom` ;

ALTER TABLE `competitions` ADD `owner_id` VARCHAR( 255 ) NOT NULL DEFAULT '' AFTER `imgurl` ;
ALTER TABLE `competitions` ADD `complete` INT( 4 ) NOT NULL AFTER `creation` ;

ALTER TABLE `clubs` ADD `owner_id` VARCHAR( 255 ) NOT NULL DEFAULT '' AFTER `id_president` ;
ALTER TABLE `clubs` ADD `complete` VARCHAR( 11 ) NOT NULL AFTER `creation` ;

ALTER TABLE `persons` ADD `aka` VARCHAR( 255 ) NOT NULL AFTER `firstname` ;
ALTER TABLE `persons` ADD `deathday` DATE NOT NULL DEFAULT '0000-00-00' AFTER `birthcity` ;

# 
# IMPORTANT
# 
# Always increase this number in createtables.sql, updatedb.sql and
# config.inc.php when changing the database structure!
# 

REPLACE INTO config (opt,value) VALUES ('dbversion', 84);
