<?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 Version20230312114756 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 course (id INT AUTO_INCREMENT NOT NULL, delivery_id INT NOT NULL, course_status_id INT NOT NULL, delivery_man_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_169E6FB912136921 (delivery_id), INDEX IDX_169E6FB9E9564011 (course_status_id), INDEX IDX_169E6FB9FD128646 (delivery_man_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tracking (id INT AUTO_INCREMENT NOT NULL, course_id INT NOT NULL, date DATETIME NOT NULL, latitude VARCHAR(255) NOT NULL, longitude VARCHAR(255) NOT NULL, INDEX IDX_A87C621C591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB912136921 FOREIGN KEY (delivery_id) REFERENCES delivery (id)');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB9E9564011 FOREIGN KEY (course_status_id) REFERENCES course_status (id)');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB9FD128646 FOREIGN KEY (delivery_man_id) REFERENCES delivery_man (id)');
$this->addSql('ALTER TABLE tracking ADD CONSTRAINT FK_A87C621C591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
$this->addSql('ALTER TABLE authorized_naf ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE compliment ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE course_status ADD date_start DATETIME NOT NULL, ADD date_end DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE course_status RENAME INDEX idx_65119c929d419299 TO IDX_D538A4519D419299');
$this->addSql('ALTER TABLE course_status RENAME INDEX idx_65119c92ac8de0f TO IDX_D538A451AC8DE0F');
$this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_270c8ccd9d419299 TO IDX_65119C929D419299');
$this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_270c8ccdac8de0f TO IDX_65119C92AC8DE0F');
$this->addSql('ALTER TABLE rank_type ADD user_type_id INT DEFAULT NULL, CHANGE min min INT DEFAULT NULL, CHANGE max max INT DEFAULT NULL');
$this->addSql('ALTER TABLE rank_type ADD CONSTRAINT FK_8A7E47D69D419299 FOREIGN KEY (user_type_id) REFERENCES user_type (id)');
$this->addSql('CREATE INDEX IDX_8A7E47D69D419299 ON rank_type (user_type_id)');
$this->addSql('ALTER TABLE stream_type ADD date_start DATETIME NOT NULL');
$this->addSql("UPDATE stream_type set date_start='1900-01-01'");
$this->addSql("UPDATE authorized_naf set date_start='1900-01-01'");
$this->addSql("UPDATE compliment set date_start='1900-01-01'");
$this->addSql("UPDATE course_status set date_start='1900-01-01'");
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB912136921');
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB9E9564011');
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB9FD128646');
$this->addSql('ALTER TABLE tracking DROP FOREIGN KEY FK_A87C621C591CC992');
$this->addSql('DROP TABLE course');
$this->addSql('DROP TABLE tracking');
$this->addSql('ALTER TABLE authorized_naf DROP date_start, DROP date_end');
$this->addSql('ALTER TABLE compliment DROP date_start, DROP date_end');
$this->addSql('ALTER TABLE course_status DROP date_start, DROP date_end');
$this->addSql('ALTER TABLE course_status RENAME INDEX idx_d538a4519d419299 TO IDX_65119C929D419299');
$this->addSql('ALTER TABLE course_status RENAME INDEX idx_d538a451ac8de0f TO IDX_65119C92AC8DE0F');
$this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_65119c929d419299 TO IDX_270C8CCD9D419299');
$this->addSql('ALTER TABLE delivery_status RENAME INDEX idx_65119c92ac8de0f TO IDX_270C8CCDAC8DE0F');
$this->addSql('ALTER TABLE rank_type DROP FOREIGN KEY FK_8A7E47D69D419299');
$this->addSql('DROP INDEX IDX_8A7E47D69D419299 ON rank_type');
$this->addSql('ALTER TABLE rank_type DROP user_type_id, CHANGE min min INT NOT NULL, CHANGE max max INT NOT NULL');
$this->addSql('ALTER TABLE stream_type DROP date_start');
}
}