<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20230918202500 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '';
    }

    public function up(Schema $schema): void
    {
        // this up() migration is auto-generated, please modify it to your needs
        $this->addSql('CREATE TABLE facility (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, address VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE file (id INT AUTO_INCREMENT NOT NULL, game_id INT DEFAULT NULL, player_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_8C9F3610E48FD905 (game_id), INDEX IDX_8C9F361099E6F5DF (player_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE game (id INT AUTO_INCREMENT NOT NULL, season_id INT DEFAULT NULL, facility_id INT DEFAULT NULL, home_team_id INT DEFAULT NULL, away_team_id INT DEFAULT NULL, points_home INT DEFAULT NULL, points_away INT DEFAULT NULL, planned_date DATETIME DEFAULT NULL, game_date_time DATETIME DEFAULT NULL, notes VARCHAR(350) DEFAULT NULL, INDEX IDX_232B318C4EC001D1 (season_id), INDEX IDX_232B318CA7014910 (facility_id), INDEX IDX_232B318C9C4C13F6 (home_team_id), INDEX IDX_232B318C45185D02 (away_team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE league (id INT AUTO_INCREMENT NOT NULL, president_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, logo VARCHAR(255) DEFAULT NULL, description VARCHAR(255) DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', points_per_win INT DEFAULT NULL, points_per_draw INT DEFAULT NULL, UNIQUE INDEX UNIQ_3EB4C318B40A33C7 (president_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE log (id INT AUTO_INCREMENT NOT NULL, payload JSON DEFAULT NULL, code INT DEFAULT NULL, message VARCHAR(550) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE player (id INT AUTO_INCREMENT NOT NULL, team_id INT DEFAULT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, position VARCHAR(255) DEFAULT NULL, jersey_number SMALLINT DEFAULT NULL, is_federated TINYINT(1) DEFAULT NULL, picture_file_name VARCHAR(255) DEFAULT NULL, birthday DATE DEFAULT NULL, INDEX IDX_98197A65296CD8AE (team_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE season (id INT AUTO_INCREMENT NOT NULL, league_id INT DEFAULT NULL, date_start DATE NOT NULL, date_end DATE DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_F0E45BA958AFC4DE (league_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE season_team (season_id INT NOT NULL, team_id INT NOT NULL, INDEX IDX_42A93A814EC001D1 (season_id), INDEX IDX_42A93A81296CD8AE (team_id), PRIMARY KEY(season_id, team_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE season_data (id INT AUTO_INCREMENT NOT NULL, team_id INT DEFAULT NULL, season_id INT DEFAULT NULL, captain_id INT DEFAULT NULL, points INT DEFAULT NULL, INDEX IDX_2BBA6FFD296CD8AE (team_id), INDEX IDX_2BBA6FFD4EC001D1 (season_id), INDEX IDX_2BBA6FFD3346729B (captain_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE team (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, phone VARCHAR(255) DEFAULT NULL, profile_picture VARCHAR(255) DEFAULT NULL, birthday DATE DEFAULT NULL, active TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F3610E48FD905 FOREIGN KEY (game_id) REFERENCES game (id)');
        $this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F361099E6F5DF FOREIGN KEY (player_id) REFERENCES player (id)');
        $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C4EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
        $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318CA7014910 FOREIGN KEY (facility_id) REFERENCES facility (id)');
        $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C9C4C13F6 FOREIGN KEY (home_team_id) REFERENCES team (id)');
        $this->addSql('ALTER TABLE game ADD CONSTRAINT FK_232B318C45185D02 FOREIGN KEY (away_team_id) REFERENCES team (id)');
        $this->addSql('ALTER TABLE league ADD CONSTRAINT FK_3EB4C318B40A33C7 FOREIGN KEY (president_id) REFERENCES user (id)');
        $this->addSql('ALTER TABLE player ADD CONSTRAINT FK_98197A65296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
        $this->addSql('ALTER TABLE season ADD CONSTRAINT FK_F0E45BA958AFC4DE FOREIGN KEY (league_id) REFERENCES league (id)');
        $this->addSql('ALTER TABLE season_team ADD CONSTRAINT FK_42A93A814EC001D1 FOREIGN KEY (season_id) REFERENCES season (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE season_team ADD CONSTRAINT FK_42A93A81296CD8AE FOREIGN KEY (team_id) REFERENCES team (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD296CD8AE FOREIGN KEY (team_id) REFERENCES team (id)');
        $this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD4EC001D1 FOREIGN KEY (season_id) REFERENCES season (id)');
        $this->addSql('ALTER TABLE season_data ADD CONSTRAINT FK_2BBA6FFD3346729B FOREIGN KEY (captain_id) REFERENCES user (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE file DROP FOREIGN KEY FK_8C9F3610E48FD905');
        $this->addSql('ALTER TABLE file DROP FOREIGN KEY FK_8C9F361099E6F5DF');
        $this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C4EC001D1');
        $this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318CA7014910');
        $this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C9C4C13F6');
        $this->addSql('ALTER TABLE game DROP FOREIGN KEY FK_232B318C45185D02');
        $this->addSql('ALTER TABLE league DROP FOREIGN KEY FK_3EB4C318B40A33C7');
        $this->addSql('ALTER TABLE player DROP FOREIGN KEY FK_98197A65296CD8AE');
        $this->addSql('ALTER TABLE season DROP FOREIGN KEY FK_F0E45BA958AFC4DE');
        $this->addSql('ALTER TABLE season_team DROP FOREIGN KEY FK_42A93A814EC001D1');
        $this->addSql('ALTER TABLE season_team DROP FOREIGN KEY FK_42A93A81296CD8AE');
        $this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD296CD8AE');
        $this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD4EC001D1');
        $this->addSql('ALTER TABLE season_data DROP FOREIGN KEY FK_2BBA6FFD3346729B');
        $this->addSql('DROP TABLE facility');
        $this->addSql('DROP TABLE file');
        $this->addSql('DROP TABLE game');
        $this->addSql('DROP TABLE league');
        $this->addSql('DROP TABLE log');
        $this->addSql('DROP TABLE player');
        $this->addSql('DROP TABLE season');
        $this->addSql('DROP TABLE season_team');
        $this->addSql('DROP TABLE season_data');
        $this->addSql('DROP TABLE team');
        $this->addSql('DROP TABLE user');
    }
}
