<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230307184358 extends AbstractMigration
{
public function getDescription(): string
{
return 'Entities for Buses';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE bus_offer (id INT AUTO_INCREMENT NOT NULL, course_id INT NOT NULL, date DATE NOT NULL, start_availability_of_seats INT NOT NULL, price DOUBLE PRECISION NOT NULL, INDEX IDX_BF8022CF591CC992 (course_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE bus_stop (id INT AUTO_INCREMENT NOT NULL, route_id INT NOT NULL, name VARCHAR(255) NOT NULL, map_url VARCHAR(255) NOT NULL, type VARCHAR(20) NOT NULL, INDEX IDX_E65B69FC34ECB4E6 (route_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE course (id INT AUTO_INCREMENT NOT NULL, route_id INT NOT NULL, name VARCHAR(255) NOT NULL, code_name VARCHAR(5) NOT NULL, start_time DATETIME NOT NULL, INDEX IDX_169E6FB934ECB4E6 (route_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE `order` (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, offer_id INT NOT NULL, status VARCHAR(255) NOT NULL, payment_method VARCHAR(255) NOT NULL, scanned_at_start DATETIME DEFAULT NULL, scanned_at_end DATETIME DEFAULT NULL, INDEX IDX_F5299398A76ED395 (user_id), INDEX IDX_F529939853C674EE (offer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE route (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, code_name VARCHAR(5) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE timetable (id INT AUTO_INCREMENT NOT NULL, bus_stop_id INT NOT NULL, date DATE NOT NULL, departure_time TIME NOT NULL, INDEX IDX_6B1F670921917F0 (bus_stop_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE transaction (id INT AUTO_INCREMENT NOT NULL, order_id INT NOT NULL, payment_method VARCHAR(255) NOT NULL, payment_key VARCHAR(255) NOT NULL, payment_status VARCHAR(255) NOT NULL, INDEX IDX_723705D18D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE bus_offer ADD CONSTRAINT FK_BF8022CF591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
$this->addSql('ALTER TABLE bus_stop ADD CONSTRAINT FK_E65B69FC34ECB4E6 FOREIGN KEY (route_id) REFERENCES route (id)');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB934ECB4E6 FOREIGN KEY (route_id) REFERENCES route (id)');
$this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F529939853C674EE FOREIGN KEY (offer_id) REFERENCES bus_offer (id)');
$this->addSql('ALTER TABLE timetable ADD CONSTRAINT FK_6B1F670921917F0 FOREIGN KEY (bus_stop_id) REFERENCES bus_stop (id)');
$this->addSql('ALTER TABLE transaction ADD CONSTRAINT FK_723705D18D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE bus_offer DROP FOREIGN KEY FK_BF8022CF591CC992');
$this->addSql('ALTER TABLE bus_stop DROP FOREIGN KEY FK_E65B69FC34ECB4E6');
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB934ECB4E6');
$this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F5299398A76ED395');
$this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F529939853C674EE');
$this->addSql('ALTER TABLE timetable DROP FOREIGN KEY FK_6B1F670921917F0');
$this->addSql('ALTER TABLE transaction DROP FOREIGN KEY FK_723705D18D9F6D38');
$this->addSql('DROP TABLE bus_offer');
$this->addSql('DROP TABLE bus_stop');
$this->addSql('DROP TABLE course');
$this->addSql('DROP TABLE `order`');
$this->addSql('DROP TABLE route');
$this->addSql('DROP TABLE timetable');
$this->addSql('DROP TABLE transaction');
}
}