
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;

#-----------------------------------------------------------------------------
#-- activation
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `activation`;


CREATE TABLE `activation`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`user_id` INTEGER  NOT NULL,
	`hash` VARCHAR(32)  NOT NULL,
	PRIMARY KEY (`id`),
	KEY `activation_hash_index`(`hash`),
	KEY `user_hash`(`user_id`, `hash`),
	CONSTRAINT `activation_FK_1`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`)
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- sf_guard_user_profile
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `sf_guard_user_profile`;


CREATE TABLE `sf_guard_user_profile`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`user_id` INTEGER  NOT NULL,
	`first_name` VARCHAR(64),
	`last_name` VARCHAR(64),
	`display_name` VARCHAR(64)  NOT NULL,
	`email` VARCHAR(100)  NOT NULL,
	`state` VARCHAR(50),
	`city` VARCHAR(80),
	`country` VARCHAR(2),
	`language` VARCHAR(2),
	`status` VARCHAR(10),
	`gmt_time` VARCHAR(30)  NOT NULL,
	PRIMARY KEY (`id`),
	KEY `sf_guard_user_profile_email_index`(`email`),
	KEY `sf_guard_user_profile_country_index`(`country`),
	KEY `sf_guard_user_profile_language_index`(`language`),
	INDEX `sf_guard_user_profile_FI_1` (`user_id`),
	CONSTRAINT `sf_guard_user_profile_FK_1`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- thema
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `thema`;


CREATE TABLE `thema`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `thema_slug_index`(`slug`),
	INDEX `thema_FI_1` (`created_by`),
	CONSTRAINT `thema_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `thema_FI_2` (`updated_by`),
	CONSTRAINT `thema_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- thema_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `thema_i18n`;


CREATE TABLE `thema_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_thema` VARCHAR(60)  NOT NULL,
	`name_male_thema` VARCHAR(30),
	`name_males_thema` VARCHAR(30),
	`name_female_thema` VARCHAR(30),
	`name_females_thema` VARCHAR(30),
	`name_team_thema` VARCHAR(30),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `thema_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `thema` (`id`)
		ON DELETE CASCADE,
	INDEX `thema_i18n_FI_2` (`validated_by`),
	CONSTRAINT `thema_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `thema_i18n_FI_3` (`created18_by`),
	CONSTRAINT `thema_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `thema_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `thema_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- season
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `season`;


CREATE TABLE `season`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(255)  NOT NULL,
	`available` INTEGER,
	`status` VARCHAR(20),
	`begin_in` SMALLINT(4),
	`finish_in` SMALLINT(4),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `season_name_index`(`name`),
	INDEX `season_FI_1` (`created_by`),
	CONSTRAINT `season_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `season_FI_2` (`updated_by`),
	CONSTRAINT `season_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- region
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `region`;


CREATE TABLE `region`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`stage` SMALLINT(3),
	`stage_up` SMALLINT(3),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `region_slug_index`(`slug`),
	INDEX `region_FI_1` (`created_by`),
	CONSTRAINT `region_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `region_FI_2` (`updated_by`),
	CONSTRAINT `region_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- region_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `region_i18n`;


CREATE TABLE `region_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name` VARCHAR(60)  NOT NULL,
	`description` VARCHAR(255),
	`statusI18n` VARCHAR(20),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `region_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `region` (`id`)
		ON DELETE CASCADE,
	INDEX `region_i18n_FI_2` (`validated_by`),
	CONSTRAINT `region_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `region_i18n_FI_3` (`created18_by`),
	CONSTRAINT `region_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `region_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `region_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- niveau
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `niveau`;


CREATE TABLE `niveau`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`thema_id` INTEGER  NOT NULL,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `niveau_slug_index`(`slug`),
	INDEX `niveau_FI_1` (`thema_id`),
	CONSTRAINT `niveau_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `niveau_FI_2` (`created_by`),
	CONSTRAINT `niveau_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `niveau_FI_3` (`updated_by`),
	CONSTRAINT `niveau_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- niveau_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `niveau_i18n`;


CREATE TABLE `niveau_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_niveau` VARCHAR(50),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `niveau_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `niveau` (`id`)
		ON DELETE CASCADE,
	INDEX `niveau_i18n_FI_2` (`validated_by`),
	CONSTRAINT `niveau_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `niveau_i18n_FI_3` (`created18_by`),
	CONSTRAINT `niveau_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `niveau_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `niveau_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- structuret_niveau
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `structuret_niveau`;


CREATE TABLE `structuret_niveau`
(
	`structuret_id` INTEGER  NOT NULL,
	`niveau_id` INTEGER  NOT NULL,
	`rank` SMALLINT(3),
	`prev` INTEGER,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`structuret_id`,`niveau_id`),
	CONSTRAINT `structuret_niveau_FK_1`
		FOREIGN KEY (`structuret_id`)
		REFERENCES `structuret` (`id`)
		ON DELETE CASCADE,
	INDEX `structuret_niveau_FI_2` (`niveau_id`),
	CONSTRAINT `structuret_niveau_FK_2`
		FOREIGN KEY (`niveau_id`)
		REFERENCES `niveau` (`id`)
		ON DELETE CASCADE,
	INDEX `structuret_niveau_FI_3` (`created_by`),
	CONSTRAINT `structuret_niveau_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_niveau_FI_4` (`updated_by`),
	CONSTRAINT `structuret_niveau_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_niveau
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_niveau`;


CREATE TABLE `tournoi_niveau`
(
	`tournoi_id` INTEGER  NOT NULL,
	`niveau_id` INTEGER  NOT NULL,
	`nb_matchs` SMALLINT(3),
	`nb_matchs_calc` SMALLINT(3),
	`nb_jokers` SMALLINT(3),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`,`niveau_id`),
	CONSTRAINT `tournoi_niveau_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_niveau_FI_2` (`niveau_id`),
	CONSTRAINT `tournoi_niveau_FK_2`
		FOREIGN KEY (`niveau_id`)
		REFERENCES `niveau` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_niveau_FI_3` (`created_by`),
	CONSTRAINT `tournoi_niveau_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_niveau_FI_4` (`updated_by`),
	CONSTRAINT `tournoi_niveau_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- structuret
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `structuret`;


CREATE TABLE `structuret`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255),
	`default_culture` VARCHAR(7),
	`prive` SMALLINT(1),
	`status` VARCHAR(20),
	`thema_id` INTEGER  NOT NULL,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `structuret_slug_index`(`slug`),
	INDEX `structuret_FI_1` (`thema_id`),
	CONSTRAINT `structuret_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_FI_2` (`created_by`),
	CONSTRAINT `structuret_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_FI_3` (`updated_by`),
	CONSTRAINT `structuret_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- structuret_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `structuret_i18n`;


CREATE TABLE `structuret_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_structuret` VARCHAR(50),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `structuret_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `structuret` (`id`)
		ON DELETE CASCADE,
	INDEX `structuret_i18n_FI_2` (`validated_by`),
	CONSTRAINT `structuret_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_i18n_FI_3` (`created18_by`),
	CONSTRAINT `structuret_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `structuret_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- structuret_admin
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `structuret_admin`;


CREATE TABLE `structuret_admin`
(
	`structuret_id` INTEGER  NOT NULL,
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`structuret_id`,`user_id`),
	CONSTRAINT `structuret_admin_FK_1`
		FOREIGN KEY (`structuret_id`)
		REFERENCES `structuret` (`id`)
		ON DELETE CASCADE,
	INDEX `structuret_admin_FI_2` (`user_id`),
	CONSTRAINT `structuret_admin_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `structuret_admin_FI_3` (`created_by`),
	CONSTRAINT `structuret_admin_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `structuret_admin_FI_4` (`updated_by`),
	CONSTRAINT `structuret_admin_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- levell
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `levell`;


CREATE TABLE `levell`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`prive` SMALLINT(3),
	`status` VARCHAR(20),
	`stage_up` SMALLINT(3),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `levell_slug_index`(`slug`),
	INDEX `levell_FI_1` (`created_by`),
	CONSTRAINT `levell_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `levell_FI_2` (`updated_by`),
	CONSTRAINT `levell_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- levell_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `levell_i18n`;


CREATE TABLE `levell_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name` VARCHAR(60)  NOT NULL,
	`description` VARCHAR(255),
	`statusI18n` VARCHAR(20),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `levell_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `levell` (`id`)
		ON DELETE CASCADE,
	INDEX `levell_i18n_FI_2` (`validated_by`),
	CONSTRAINT `levell_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `levell_i18n_FI_3` (`created18_by`),
	CONSTRAINT `levell_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `levell_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `levell_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- levell_thema
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `levell_thema`;


CREATE TABLE `levell_thema`
(
	`levell_id` INTEGER  NOT NULL,
	`thema_id` INTEGER  NOT NULL,
	PRIMARY KEY (`levell_id`,`thema_id`),
	CONSTRAINT `levell_thema_FK_1`
		FOREIGN KEY (`levell_id`)
		REFERENCES `levell` (`id`)
		ON DELETE CASCADE,
	INDEX `levell_thema_FI_2` (`thema_id`),
	CONSTRAINT `levell_thema_FK_2`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- category
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `category`;


CREATE TABLE `category`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`thema_id` INTEGER  NOT NULL,
	`levell_id` SMALLINT(2)  NOT NULL,
	`prive` INTEGER,
	`status` VARCHAR(20),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `category_slug_index`(`slug`),
	INDEX `category_FI_1` (`thema_id`),
	CONSTRAINT `category_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `category_FI_2` (`levell_id`),
	CONSTRAINT `category_FK_2`
		FOREIGN KEY (`levell_id`)
		REFERENCES `levell` (`id`)
		ON DELETE CASCADE,
	INDEX `category_FI_3` (`created_by`),
	CONSTRAINT `category_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `category_FI_4` (`updated_by`),
	CONSTRAINT `category_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- category_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `category_i18n`;


CREATE TABLE `category_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_category` VARCHAR(255)  NOT NULL,
	`statusI18n` VARCHAR(20),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `category_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `category` (`id`)
		ON DELETE CASCADE,
	INDEX `category_i18n_FI_2` (`validated_by`),
	CONSTRAINT `category_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `category_i18n_FI_3` (`created18_by`),
	CONSTRAINT `category_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `category_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `category_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- rules
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `rules`;


CREATE TABLE `rules`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`thema_id` INTEGER  NOT NULL,
	`default_culture` VARCHAR(7)  NOT NULL,
	`status` VARCHAR(20),
	`prive` SMALLINT(1),
	`play_favori` INTEGER,
	`def_points` VARCHAR(255),
	`bet_type_id` SMALLINT(11),
	`type_bet_type` VARCHAR(12),
	`nb_X` SMALLINT(3),
	`jokerm` INTEGER,
	`who_inputs` SMALLINT(1),
	`percent_of_inputs` SMALLINT(3),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `rules_slug_index`(`slug`),
	INDEX `rules_FI_1` (`thema_id`),
	CONSTRAINT `rules_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_FI_2` (`bet_type_id`),
	CONSTRAINT `rules_FK_2`
		FOREIGN KEY (`bet_type_id`)
		REFERENCES `bet_type` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_FI_3` (`created_by`),
	CONSTRAINT `rules_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_FI_4` (`updated_by`),
	CONSTRAINT `rules_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- rules_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `rules_i18n`;


CREATE TABLE `rules_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_rules` VARCHAR(60),
	`name_favori` VARCHAR(60),
	`name_win` VARCHAR(60),
	`name_lose` VARCHAR(60),
	`name_nul` VARCHAR(60),
	`name_bonus1` VARCHAR(60),
	`name_bonus2` VARCHAR(60),
	`name_joker1` VARCHAR(60),
	`name_joker2` VARCHAR(60),
	`name_bonusm` VARCHAR(60),
	`name_malusm` VARCHAR(60),
	`name_jokerm` VARCHAR(60),
	`bet_on` VARCHAR(30),
	`def_win` TEXT,
	`def_lose` TEXT,
	`def_nul` TEXT,
	`def_bonus1` TEXT,
	`def_bonus2` TEXT,
	`def_joker1` TEXT,
	`def_joker2` TEXT,
	`def_bonusm` TEXT,
	`def_malusm` TEXT,
	`def_jokerm` TEXT,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `rules_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `rules` (`id`)
		ON DELETE CASCADE,
	INDEX `rules_i18n_FI_2` (`validated_by`),
	CONSTRAINT `rules_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_i18n_FI_3` (`created18_by`),
	CONSTRAINT `rules_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `rules_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- rules_admin
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `rules_admin`;


CREATE TABLE `rules_admin`
(
	`rules_id` INTEGER  NOT NULL,
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`rules_id`,`user_id`),
	CONSTRAINT `rules_admin_FK_1`
		FOREIGN KEY (`rules_id`)
		REFERENCES `rules` (`id`)
		ON DELETE CASCADE,
	INDEX `rules_admin_FI_2` (`user_id`),
	CONSTRAINT `rules_admin_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `rules_admin_FI_3` (`created_by`),
	CONSTRAINT `rules_admin_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `rules_admin_FI_4` (`updated_by`),
	CONSTRAINT `rules_admin_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- bet_type
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `bet_type`;


CREATE TABLE `bet_type`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `bet_type_FI_1` (`created_by`),
	CONSTRAINT `bet_type_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `bet_type_FI_2` (`updated_by`),
	CONSTRAINT `bet_type_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- bet_type_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `bet_type_i18n`;


CREATE TABLE `bet_type_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_bet_type` VARCHAR(255)  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `bet_type_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `bet_type` (`id`)
		ON DELETE CASCADE,
	INDEX `bet_type_i18n_FI_2` (`validated_by`),
	CONSTRAINT `bet_type_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `bet_type_i18n_FI_3` (`created18_by`),
	CONSTRAINT `bet_type_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `bet_type_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `bet_type_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi`;


CREATE TABLE `tournoi`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`category_id` INTEGER,
	`thema_id` INTEGER  NOT NULL,
	`rules_id` INTEGER,
	`place_id` INTEGER,
	`structuret_id` INTEGER,
	`group_team_id` INTEGER,
	`status` VARCHAR(18),
	`prive` SMALLINT(1),
	`teams_type` VARCHAR(3),
	`tz` VARCHAR(40)  NOT NULL,
	`open_at` DATETIME,
	`begin_at` DATETIME,
	`finish_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `tournoi_slug_index`(`slug`),
	INDEX `tournoi_FI_1` (`category_id`),
	CONSTRAINT `tournoi_FK_1`
		FOREIGN KEY (`category_id`)
		REFERENCES `category` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_2` (`thema_id`),
	CONSTRAINT `tournoi_FK_2`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_3` (`rules_id`),
	CONSTRAINT `tournoi_FK_3`
		FOREIGN KEY (`rules_id`)
		REFERENCES `rules` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_4` (`place_id`),
	CONSTRAINT `tournoi_FK_4`
		FOREIGN KEY (`place_id`)
		REFERENCES `place` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_5` (`structuret_id`),
	CONSTRAINT `tournoi_FK_5`
		FOREIGN KEY (`structuret_id`)
		REFERENCES `structuret` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_6` (`group_team_id`),
	CONSTRAINT `tournoi_FK_6`
		FOREIGN KEY (`group_team_id`)
		REFERENCES `group_team` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_7` (`created_by`),
	CONSTRAINT `tournoi_FK_7`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_FI_8` (`updated_by`),
	CONSTRAINT `tournoi_FK_8`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_i18n`;


CREATE TABLE `tournoi_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_tournoi` VARCHAR(255)  NOT NULL,
	`short_description` VARCHAR(255)  NOT NULL,
	`full_description` TEXT  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `tournoi_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_i18n_FI_2` (`validated_by`),
	CONSTRAINT `tournoi_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_i18n_FI_3` (`created18_by`),
	CONSTRAINT `tournoi_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `tournoi_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- event
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `event`;


CREATE TABLE `event`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`place_id` INTEGER,
	`thema_id` INTEGER  NOT NULL,
	`status` VARCHAR(18),
	`prive` SMALLINT(1),
	`region1` SMALLINT(6),
	`region2` VARCHAR(30),
	`country` VARCHAR(2),
	`name_or_pseudo` SMALLINT(1),
	`max_players` SMALLINT(6),
	`game_player` INTEGER,
	`game_team` INTEGER,
	`min_team` SMALLINT(6),
	`max_team` SMALLINT(6),
	`point_team_from` SMALLINT(6),
	`origine` INTEGER,
	`register_at` DATETIME,
	`begin_at` DATETIME,
	`finish_at` DATETIME,
	`register_code` VARCHAR(20),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `event_slug_index`(`slug`),
	KEY `event_country_index`(`country`),
	INDEX `event_FI_1` (`place_id`),
	CONSTRAINT `event_FK_1`
		FOREIGN KEY (`place_id`)
		REFERENCES `place` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_2` (`thema_id`),
	CONSTRAINT `event_FK_2`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_3` (`region1`),
	CONSTRAINT `event_FK_3`
		FOREIGN KEY (`region1`)
		REFERENCES `region` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_4` (`region2`),
	CONSTRAINT `event_FK_4`
		FOREIGN KEY (`region2`)
		REFERENCES `region` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_5` (`origine`),
	CONSTRAINT `event_FK_5`
		FOREIGN KEY (`origine`)
		REFERENCES `event` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_6` (`created_by`),
	CONSTRAINT `event_FK_6`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `event_FI_7` (`updated_by`),
	CONSTRAINT `event_FK_7`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- event_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `event_i18n`;


CREATE TABLE `event_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_event` VARCHAR(255)  NOT NULL,
	`short_description` VARCHAR(255)  NOT NULL,
	`full_description` TEXT  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `event_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `event_i18n_FI_2` (`validated_by`),
	CONSTRAINT `event_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `event_i18n_FI_3` (`created18_by`),
	CONSTRAINT `event_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `event_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `event_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- event_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `event_player`;


CREATE TABLE `event_player`
(
	`event_id` INTEGER  NOT NULL,
	`player_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`event_id`,`player_id`),
	CONSTRAINT `event_player_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `event_player_FI_2` (`player_id`),
	CONSTRAINT `event_player_FK_2`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `event_player_FI_3` (`created_by`),
	CONSTRAINT `event_player_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `event_player_FI_4` (`updated_by`),
	CONSTRAINT `event_player_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- event_admin
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `event_admin`;


CREATE TABLE `event_admin`
(
	`event_id` INTEGER  NOT NULL,
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`event_id`,`user_id`),
	CONSTRAINT `event_admin_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `event_admin_FI_2` (`user_id`),
	CONSTRAINT `event_admin_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `event_admin_FI_3` (`created_by`),
	CONSTRAINT `event_admin_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `event_admin_FI_4` (`updated_by`),
	CONSTRAINT `event_admin_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_admin
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_admin`;


CREATE TABLE `tournoi_admin`
(
	`tournoi_id` INTEGER  NOT NULL,
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`,`user_id`),
	CONSTRAINT `tournoi_admin_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_admin_FI_2` (`user_id`),
	CONSTRAINT `tournoi_admin_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `tournoi_admin_FI_3` (`created_by`),
	CONSTRAINT `tournoi_admin_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_admin_FI_4` (`updated_by`),
	CONSTRAINT `tournoi_admin_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_player`;


CREATE TABLE `tournoi_player`
(
	`tournoi_id` INTEGER  NOT NULL,
	`player_id` INTEGER  NOT NULL,
	`hpronos` VARCHAR(32),
	`strpronos` TEXT,
	`points` TEXT,
	`favori` VARCHAR(6),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`,`player_id`),
	KEY `player_hpronos_index`(`hpronos`),
	CONSTRAINT `tournoi_player_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_player_FI_2` (`player_id`),
	CONSTRAINT `tournoi_player_FK_2`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_player_FI_3` (`created_by`),
	CONSTRAINT `tournoi_player_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_player_FI_4` (`updated_by`),
	CONSTRAINT `tournoi_player_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_event
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_event`;


CREATE TABLE `tournoi_event`
(
	`tournoi_id` INTEGER  NOT NULL,
	`event_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`,`event_id`),
	CONSTRAINT `tournoi_event_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_event_FI_2` (`event_id`),
	CONSTRAINT `tournoi_event_FK_2`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_event_FI_3` (`created_by`),
	CONSTRAINT `tournoi_event_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_event_FI_4` (`updated_by`),
	CONSTRAINT `tournoi_event_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `player`;


CREATE TABLE `player`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`user_id` INTEGER  NOT NULL,
	`event_id` INTEGER  NOT NULL,
	`status` VARCHAR(20),
	`team_player_id` INTEGER(3),
	`points` SMALLINT(12),
	`is_active` INTEGER  NOT NULL,
	`captain` INTEGER  NOT NULL,
	`modif_captain` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `player_FI_1` (`user_id`),
	CONSTRAINT `player_FK_1`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE CASCADE,
	INDEX `player_FI_2` (`event_id`),
	CONSTRAINT `player_FK_2`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `player_FI_3` (`team_player_id`),
	CONSTRAINT `player_FK_3`
		FOREIGN KEY (`team_player_id`)
		REFERENCES `team_player` (`id`),
	INDEX `player_FI_4` (`created_by`),
	CONSTRAINT `player_FK_4`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `player_FI_5` (`updated_by`),
	CONSTRAINT `player_FK_5`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- team_thema
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `team_thema`;


CREATE TABLE `team_thema`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`thema_id` INTEGER  NOT NULL,
	`country` VARCHAR(2)  NOT NULL,
	`prive` INTEGER,
	`status` VARCHAR(20),
	`team_type` INTEGER(1),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `team_thema_country_index`(`country`),
	INDEX `team_thema_FI_1` (`thema_id`),
	CONSTRAINT `team_thema_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE SET NULL,
	INDEX `team_thema_FI_2` (`created_by`),
	CONSTRAINT `team_thema_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `team_thema_FI_3` (`updated_by`),
	CONSTRAINT `team_thema_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- team_thema_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `team_thema_i18n`;


CREATE TABLE `team_thema_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`sigle` VARCHAR(16),
	`name_team_thema` VARCHAR(255)  NOT NULL,
	`name_player` VARCHAR(255)  NOT NULL,
	`surname_player` VARCHAR(255)  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `team_thema_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `team_thema` (`id`)
		ON DELETE CASCADE,
	INDEX `team_thema_i18n_FI_2` (`validated_by`),
	CONSTRAINT `team_thema_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `team_thema_i18n_FI_3` (`created18_by`),
	CONSTRAINT `team_thema_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `team_thema_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `team_thema_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- group_team
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `group_team`;


CREATE TABLE `group_team`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`name` VARCHAR(60)  NOT NULL,
	`status` VARCHAR(18),
	`prive` SMALLINT(1),
	`teams_type` VARCHAR(3)  NOT NULL,
	`nb_teams` SMALLINT(3),
	`thema_id` INTEGER  NOT NULL,
	`season_id` INTEGER,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `group_team_FI_1` (`thema_id`),
	CONSTRAINT `group_team_FK_1`
		FOREIGN KEY (`thema_id`)
		REFERENCES `thema` (`id`)
		ON DELETE CASCADE,
	INDEX `group_team_FI_2` (`season_id`),
	CONSTRAINT `group_team_FK_2`
		FOREIGN KEY (`season_id`)
		REFERENCES `season` (`id`)
		ON DELETE SET NULL,
	INDEX `group_team_FI_3` (`created_by`),
	CONSTRAINT `group_team_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `group_team_FI_4` (`updated_by`),
	CONSTRAINT `group_team_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- group_team_custom
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `group_team_custom`;


CREATE TABLE `group_team_custom`
(
	`group_team_id` INTEGER  NOT NULL,
	`team_thema_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`group_team_id`,`team_thema_id`),
	CONSTRAINT `group_team_custom_FK_1`
		FOREIGN KEY (`group_team_id`)
		REFERENCES `group_team` (`id`)
		ON DELETE CASCADE,
	INDEX `group_team_custom_FI_2` (`team_thema_id`),
	CONSTRAINT `group_team_custom_FK_2`
		FOREIGN KEY (`team_thema_id`)
		REFERENCES `team_thema` (`id`)
		ON DELETE CASCADE,
	INDEX `group_team_custom_FI_3` (`created_by`),
	CONSTRAINT `group_team_custom_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `group_team_custom_FI_4` (`updated_by`),
	CONSTRAINT `group_team_custom_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_team_thema
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_team_thema`;


CREATE TABLE `tournoi_team_thema`
(
	`tournoi_id` INTEGER  NOT NULL,
	`team_thema_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`,`team_thema_id`),
	CONSTRAINT `tournoi_team_thema_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_team_thema_FI_2` (`team_thema_id`),
	CONSTRAINT `tournoi_team_thema_FK_2`
		FOREIGN KEY (`team_thema_id`)
		REFERENCES `team_thema` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_team_thema_FI_3` (`created_by`),
	CONSTRAINT `tournoi_team_thema_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_team_thema_FI_4` (`updated_by`),
	CONSTRAINT `tournoi_team_thema_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- group_team_national
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `group_team_national`;


CREATE TABLE `group_team_national`
(
	`group_team_id` INTEGER  NOT NULL,
	`list_national_teams` TEXT,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`group_team_id`),
	CONSTRAINT `group_team_national_FK_1`
		FOREIGN KEY (`group_team_id`)
		REFERENCES `group_team` (`id`)
		ON DELETE CASCADE,
	INDEX `group_team_national_FI_2` (`created_by`),
	CONSTRAINT `group_team_national_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `group_team_national_FI_3` (`updated_by`),
	CONSTRAINT `group_team_national_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- tournoi_list_teams
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `tournoi_list_teams`;


CREATE TABLE `tournoi_list_teams`
(
	`tournoi_id` INTEGER  NOT NULL,
	`list_national_teams` TEXT,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`tournoi_id`),
	CONSTRAINT `tournoi_list_teams_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `tournoi_list_teams_FI_2` (`created_by`),
	CONSTRAINT `tournoi_list_teams_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `tournoi_list_teams_FI_3` (`updated_by`),
	CONSTRAINT `tournoi_list_teams_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- matchs
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `matchs`;


CREATE TABLE `matchs`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`tournoi_id` INTEGER  NOT NULL,
	`match_name` VARCHAR(64),
	`team_thema1_id` VARCHAR(6),
	`team_thema2_id` VARCHAR(6),
	`score_eq1` SMALLINT(4),
	`result` VARCHAR(1),
	`score_eq2` SMALLINT(4),
	`bonus_eq1` SMALLINT(4),
	`bonus_eq2` SMALLINT(4),
	`malus_eq1` SMALLINT(4),
	`malus_eq2` SMALLINT(4),
	`classement` VARCHAR(64),
	`verrou` INTEGER,
	`calcul` INTEGER,
	`calcul_result` INTEGER,
	`nom_alt1` VARCHAR(60),
	`nom_alt2` VARCHAR(60),
	`date` DATETIME,
	`niveau_id` INTEGER  NOT NULL,
	`place_id` INTEGER,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `matchs_FI_1` (`tournoi_id`),
	CONSTRAINT `matchs_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `matchs_FI_2` (`niveau_id`),
	CONSTRAINT `matchs_FK_2`
		FOREIGN KEY (`niveau_id`)
		REFERENCES `niveau` (`id`)
		ON DELETE SET NULL,
	INDEX `matchs_FI_3` (`place_id`),
	CONSTRAINT `matchs_FK_3`
		FOREIGN KEY (`place_id`)
		REFERENCES `place` (`id`)
		ON DELETE SET NULL,
	INDEX `matchs_FI_4` (`created_by`),
	CONSTRAINT `matchs_FK_4`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `matchs_FI_5` (`updated_by`),
	CONSTRAINT `matchs_FK_5`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- place
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `place`;


CREATE TABLE `place`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`slug` VARCHAR(255)  NOT NULL,
	`default_culture` VARCHAR(7),
	`country` VARCHAR(2),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `place_FI_1` (`created_by`),
	CONSTRAINT `place_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `place_FI_2` (`updated_by`),
	CONSTRAINT `place_FK_2`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- place_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `place_i18n`;


CREATE TABLE `place_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`name_place` VARCHAR(255)  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`validated_at` DATETIME,
	`validated_by` INTEGER,
	`created18_by` INTEGER,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `place_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `place` (`id`)
		ON DELETE CASCADE,
	INDEX `place_i18n_FI_2` (`validated_by`),
	CONSTRAINT `place_i18n_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `place_i18n_FI_3` (`created18_by`),
	CONSTRAINT `place_i18n_FK_3`
		FOREIGN KEY (`created18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `place_i18n_FI_4` (`updated18_by`),
	CONSTRAINT `place_i18n_FK_4`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- penalties_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `penalties_player`;


CREATE TABLE `penalties_player`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`player_id` INTEGER  NOT NULL,
	`penalties` SMALLINT(4)  NOT NULL,
	`reason` VARCHAR(255),
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `penalties_player_FI_1` (`player_id`),
	CONSTRAINT `penalties_player_FK_1`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `penalties_player_FI_2` (`user_id`),
	CONSTRAINT `penalties_player_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `penalties_player_FI_3` (`created_by`),
	CONSTRAINT `penalties_player_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `penalties_player_FI_4` (`updated_by`),
	CONSTRAINT `penalties_player_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- penalties_team_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `penalties_team_player`;


CREATE TABLE `penalties_team_player`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`team_player_id` INTEGER  NOT NULL,
	`penalties` SMALLINT(4)  NOT NULL,
	`reason` VARCHAR(255),
	`user_id` INTEGER  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `penalties_team_player_FI_1` (`team_player_id`),
	CONSTRAINT `penalties_team_player_FK_1`
		FOREIGN KEY (`team_player_id`)
		REFERENCES `team_player` (`id`)
		ON DELETE CASCADE,
	INDEX `penalties_team_player_FI_2` (`user_id`),
	CONSTRAINT `penalties_team_player_FK_2`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`),
	INDEX `penalties_team_player_FI_3` (`created_by`),
	CONSTRAINT `penalties_team_player_FK_3`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `penalties_team_player_FI_4` (`updated_by`),
	CONSTRAINT `penalties_team_player_FK_4`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- team_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `team_player`;


CREATE TABLE `team_player`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`event_id` INTEGER,
	`name_team_player` VARCHAR(120)  NOT NULL,
	`points` SMALLINT(4),
	`prive` INTEGER,
	`status` VARCHAR(20),
	`nb_players` SMALLINT(6),
	`register_code` VARCHAR(20),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`id`),
	KEY `team_player_name_index`(`name_team_player`),
	INDEX `team_player_FI_1` (`event_id`),
	CONSTRAINT `team_player_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`),
	INDEX `team_player_FI_2` (`created_by`),
	CONSTRAINT `team_player_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `team_player_FI_3` (`updated_by`),
	CONSTRAINT `team_player_FK_3`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- palmares_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `palmares_player`;


CREATE TABLE `palmares_player`
(
	`user_id` INTEGER  NOT NULL,
	`event_id` INTEGER  NOT NULL,
	`team_player_id` INTEGER,
	`points_indiv` SMALLINT(6),
	`class_indiv` SMALLINT(6),
	`indiv_exaequo` INTEGER,
	`class_general` SMALLINT(6),
	`general_exaequo` INTEGER,
	`points_team` SMALLINT(6),
	`class_team_player` SMALLINT(6),
	`team_exaequo` INTEGER,
	`class_player_in_team` SMALLINT(6),
	`nb_players_team` SMALLINT(6),
	`in_team_exaequo` INTEGER,
	`created_at` DATETIME,
	`created_by` INTEGER,
	PRIMARY KEY (`user_id`,`event_id`),
	CONSTRAINT `palmares_player_FK_1`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE CASCADE,
	INDEX `palmares_player_FI_2` (`event_id`),
	CONSTRAINT `palmares_player_FK_2`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `palmares_player_FI_3` (`team_player_id`),
	CONSTRAINT `palmares_player_FK_3`
		FOREIGN KEY (`team_player_id`)
		REFERENCES `team_player` (`id`),
	INDEX `palmares_player_FI_4` (`created_by`),
	CONSTRAINT `palmares_player_FK_4`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- palmares_event
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `palmares_event`;


CREATE TABLE `palmares_event`
(
	`event_id` INTEGER  NOT NULL,
	`nb_players` SMALLINT(6),
	`points_best_player` SMALLINT(6),
	`nb_players_general` SMALLINT(6),
	`points_best_player_general` SMALLINT(6),
	`nb_teams` SMALLINT(6),
	`points_best_team` SMALLINT(6),
	`created_at` DATETIME,
	`created_by` INTEGER,
	PRIMARY KEY (`event_id`),
	CONSTRAINT `palmares_event_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `palmares_event_FI_2` (`created_by`),
	CONSTRAINT `palmares_event_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- pronos
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `pronos`;


CREATE TABLE `pronos`
(
	`player_id` INTEGER  NOT NULL,
	`tournoi_id` INTEGER  NOT NULL,
	`matchs_id` INTEGER  NOT NULL,
	`pari_eq1` SMALLINT(4),
	`pari_nul` SMALLINT(4),
	`pari_eq2` SMALLINT(4),
	`classement` VARCHAR(64),
	`bonus1` SMALLINT(4),
	`bonus2` SMALLINT(4),
	`bonusm` SMALLINT(4),
	`joker1` INTEGER,
	`joker2` INTEGER,
	`jokerm` SMALLINT(1),
	`points` SMALLINT(4),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	`created_by` INTEGER,
	`updated_by` INTEGER,
	PRIMARY KEY (`player_id`,`tournoi_id`,`matchs_id`),
	CONSTRAINT `pronos_FK_1`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `pronos_FI_2` (`tournoi_id`),
	CONSTRAINT `pronos_FK_2`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `pronos_FI_3` (`matchs_id`),
	CONSTRAINT `pronos_FK_3`
		FOREIGN KEY (`matchs_id`)
		REFERENCES `matchs` (`id`)
		ON DELETE CASCADE,
	INDEX `pronos_FI_4` (`created_by`),
	CONSTRAINT `pronos_FK_4`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `pronos_FI_5` (`updated_by`),
	CONSTRAINT `pronos_FK_5`
		FOREIGN KEY (`updated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- team_player_compo
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `team_player_compo`;


CREATE TABLE `team_player_compo`
(
	`event_id` INTEGER  NOT NULL,
	`player_id` INTEGER  NOT NULL,
	`team_player_id` INTEGER  NOT NULL,
	`status_player` SMALLINT(4),
	`status_captain` SMALLINT(4),
	`nb_demands_player` SMALLINT(4),
	`nb_demands_captain` SMALLINT(4),
	`created_at` DATETIME,
	`updated_at` DATETIME,
	PRIMARY KEY (`event_id`,`player_id`,`team_player_id`),
	CONSTRAINT `team_player_compo_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `team_player_compo_FI_2` (`player_id`),
	CONSTRAINT `team_player_compo_FK_2`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `team_player_compo_FI_3` (`team_player_id`),
	CONSTRAINT `team_player_compo_FK_3`
		FOREIGN KEY (`team_player_id`)
		REFERENCES `team_player` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- team_player_histo
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `team_player_histo`;


CREATE TABLE `team_player_histo`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`event_id` INTEGER  NOT NULL,
	`player_id` INTEGER  NOT NULL,
	`team_player_id` INTEGER  NOT NULL,
	`what` VARCHAR(80)  NOT NULL,
	`created_at` DATETIME,
	`updated_at` DATETIME,
	PRIMARY KEY (`id`),
	INDEX `team_player_histo_FI_1` (`event_id`),
	CONSTRAINT `team_player_histo_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE,
	INDEX `team_player_histo_FI_2` (`player_id`),
	CONSTRAINT `team_player_histo_FK_2`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `team_player_histo_FI_3` (`team_player_id`),
	CONSTRAINT `team_player_histo_FK_3`
		FOREIGN KEY (`team_player_id`)
		REFERENCES `team_player` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- input_result
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `input_result`;


CREATE TABLE `input_result`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`tournoi_id` INTEGER  NOT NULL,
	`match_id` INTEGER  NOT NULL,
	`score_eq1` SMALLINT(4),
	`score_eq2` SMALLINT(4),
	`result` SMALLINT(4),
	`classement` VARCHAR(80),
	`nb_score` SMALLINT(4),
	`nb_result` SMALLINT(4),
	`nb_order` SMALLINT(4),
	PRIMARY KEY (`id`),
	INDEX `input_result_FI_1` (`tournoi_id`),
	CONSTRAINT `input_result_FK_1`
		FOREIGN KEY (`tournoi_id`)
		REFERENCES `tournoi` (`id`)
		ON DELETE CASCADE,
	INDEX `input_result_FI_2` (`match_id`),
	CONSTRAINT `input_result_FK_2`
		FOREIGN KEY (`match_id`)
		REFERENCES `matchs` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- input_by_player
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `input_by_player`;


CREATE TABLE `input_by_player`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`player_id` INTEGER  NOT NULL,
	`input_result_id` INTEGER  NOT NULL,
	PRIMARY KEY (`id`),
	INDEX `input_by_player_FI_1` (`player_id`),
	CONSTRAINT `input_by_player_FK_1`
		FOREIGN KEY (`player_id`)
		REFERENCES `player` (`id`)
		ON DELETE CASCADE,
	INDEX `input_by_player_FI_2` (`input_result_id`),
	CONSTRAINT `input_by_player_FK_2`
		FOREIGN KEY (`input_result_id`)
		REFERENCES `input_result` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- news
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `news`;


CREATE TABLE `news`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`event_id` INTEGER  NOT NULL,
	`tournoi_id` INTEGER(11),
	`default_culture` VARCHAR(7),
	PRIMARY KEY (`id`),
	INDEX `news_FI_1` (`event_id`),
	CONSTRAINT `news_FK_1`
		FOREIGN KEY (`event_id`)
		REFERENCES `event` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- news_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `news_i18n`;


CREATE TABLE `news_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`message` TEXT,
	`updated_at` DATETIME,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `news_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `news` (`id`)
		ON DELETE CASCADE,
	INDEX `news_i18n_FI_2` (`updated18_by`),
	CONSTRAINT `news_i18n_FK_2`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- admin_text
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `admin_text`;


CREATE TABLE `admin_text`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`default_culture` VARCHAR(7),
	`status` SMALLINT(4),
	`page_name` VARCHAR(16),
	PRIMARY KEY (`id`)
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- admin_text_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `admin_text_i18n`;


CREATE TABLE `admin_text_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`text_by_admin` TEXT,
	`updated_at` DATETIME,
	`updated18_by` INTEGER,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `admin_text_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `admin_text` (`id`)
		ON DELETE CASCADE,
	INDEX `admin_text_i18n_FI_2` (`updated18_by`),
	CONSTRAINT `admin_text_i18n_FK_2`
		FOREIGN KEY (`updated18_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- links
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `links`;


CREATE TABLE `links`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`type` VARCHAR(18),
	`value` VARCHAR(11),
	`status` VARCHAR(8),
	`comment` TEXT,
	`created_at` DATETIME,
	`validated_at` DATETIME,
	`created_by` INTEGER,
	`validated_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `links_FI_1` (`created_by`),
	CONSTRAINT `links_FK_1`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL,
	INDEX `links_FI_2` (`validated_by`),
	CONSTRAINT `links_FK_2`
		FOREIGN KEY (`validated_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- links_i18n
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `links_i18n`;


CREATE TABLE `links_i18n`
(
	`id` INTEGER  NOT NULL,
	`culture` VARCHAR(7)  NOT NULL,
	`link` TEXT,
	`description` TEXT,
	PRIMARY KEY (`id`,`culture`),
	CONSTRAINT `links_i18n_FK_1`
		FOREIGN KEY (`id`)
		REFERENCES `links` (`id`)
		ON DELETE CASCADE
)Type=InnoDB;

#-----------------------------------------------------------------------------
#-- notice_to_user
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `notice_to_user`;


CREATE TABLE `notice_to_user`
(
	`id` INTEGER  NOT NULL AUTO_INCREMENT,
	`user_id` INTEGER,
	`notice` VARCHAR(64),
	`created_at` DATETIME,
	`created_by` INTEGER,
	PRIMARY KEY (`id`),
	INDEX `notice_to_user_FI_1` (`user_id`),
	CONSTRAINT `notice_to_user_FK_1`
		FOREIGN KEY (`user_id`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE CASCADE,
	INDEX `notice_to_user_FI_2` (`created_by`),
	CONSTRAINT `notice_to_user_FK_2`
		FOREIGN KEY (`created_by`)
		REFERENCES `sf_guard_user` (`id`)
		ON DELETE SET NULL
)Type=InnoDB;

# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
