<?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 Version20200505104020 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE athlete (strava_id INT NOT NULL, username VARCHAR(180) NOT NULL, refresh_token VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_C03B8321F85E0677 (username), PRIMARY KEY(strava_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE athlete_token (access_token VARCHAR(180) NOT NULL, strava_id INT DEFAULT NULL, expired_at DATETIME NOT NULL, scope VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_593CB896D36AF002 (strava_id), PRIMARY KEY(access_token)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE athlete_token ADD CONSTRAINT FK_593CB896D36AF002 FOREIGN KEY (strava_id) REFERENCES athlete (strava_id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE athlete_token DROP FOREIGN KEY FK_593CB896D36AF002');
$this->addSql('DROP TABLE athlete');
$this->addSql('DROP TABLE athlete_token');
}
}