<?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 Version20221124221210 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 order_detail (id INT AUTO_INCREMENT NOT NULL, order_id INT DEFAULT NULL, item VARCHAR(255) NOT NULL, pvp NUMERIC(10, 3) NOT NULL, quantity INT NOT NULL, total NUMERIC(10, 3) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_ED896F468D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('CREATE TABLE tracking_order (id INT AUTO_INCREMENT NOT NULL, order_id INT DEFAULT NULL, code INT DEFAULT NULL COMMENT \'Event Code\', reference INT DEFAULT NULL COMMENT \'Id reference, depends of code\', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_1E758A358D9F6D38 (order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE order_detail ADD CONSTRAINT FK_ED896F468D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)');
        $this->addSql('ALTER TABLE tracking_order ADD CONSTRAINT FK_1E758A358D9F6D38 FOREIGN KEY (order_id) REFERENCES `order` (id)');
        $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F52993981C8438BC');
        $this->addSql('DROP INDEX IDX_F52993981C8438BC ON `order`');
        $this->addSql('ALTER TABLE `order` ADD payment_type VARCHAR(2) NOT NULL, ADD entity VARCHAR(10) DEFAULT NULL, ADD reference VARCHAR(12) DEFAULT NULL, ADD payment_uid VARCHAR(70) DEFAULT NULL, ADD payment_status VARCHAR(1) NOT NULL, ADD payment_date DATETIME DEFAULT NULL, CHANGE order_restaurant_id restaurant_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398B1E7706E FOREIGN KEY (restaurant_id) REFERENCES restaurant (id)');
        $this->addSql('CREATE INDEX IDX_F5299398B1E7706E ON `order` (restaurant_id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE order_detail DROP FOREIGN KEY FK_ED896F468D9F6D38');
        $this->addSql('ALTER TABLE tracking_order DROP FOREIGN KEY FK_1E758A358D9F6D38');
        $this->addSql('DROP TABLE order_detail');
        $this->addSql('DROP TABLE tracking_order');
        $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F5299398B1E7706E');
        $this->addSql('DROP INDEX IDX_F5299398B1E7706E ON `order`');
        $this->addSql('ALTER TABLE `order` DROP payment_type, DROP entity, DROP reference, DROP payment_uid, DROP payment_status, DROP payment_date, CHANGE restaurant_id order_restaurant_id INT DEFAULT NULL');
        $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F52993981C8438BC FOREIGN KEY (order_restaurant_id) REFERENCES restaurant (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
        $this->addSql('CREATE INDEX IDX_F52993981C8438BC ON `order` (order_restaurant_id)');
    }
}
