<?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 Version20221124182854 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` (id INT AUTO_INCREMENT NOT NULL, order_restaurant_id INT DEFAULT NULL, client_user_id INT DEFAULT NULL, deliveryman_user_id INT DEFAULT NULL, send_now TINYINT(1) NOT NULL COMMENT \'Is delivered now? yes or not\', delivery_date DATETIME DEFAULT NULL COMMENT \'If not delivered now, when?\', subtotal NUMERIC(10, 3) NOT NULL, fee NUMERIC(10, 3) NOT NULL, total NUMERIC(10, 3) NOT NULL, code VARCHAR(20) NOT NULL COMMENT \'This code is the one that the user will use to identify the order\', status VARCHAR(1) NOT NULL, address_destination VARCHAR(500) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, deleted_at DATETIME DEFAULT NULL, INDEX IDX_F52993981C8438BC (order_restaurant_id), UNIQUE INDEX UNIQ_F5299398F55397E8 (client_user_id), UNIQUE INDEX UNIQ_F52993989149D576 (deliveryman_user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
        $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F52993981C8438BC FOREIGN KEY (order_restaurant_id) REFERENCES restaurant (id)');
        $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F5299398F55397E8 FOREIGN KEY (client_user_id) REFERENCES user (id)');
        $this->addSql('ALTER TABLE `order` ADD CONSTRAINT FK_F52993989149D576 FOREIGN KEY (deliveryman_user_id) REFERENCES user (id)');
        $this->addSql('ALTER TABLE extra DROP FOREIGN KEY FK_4D3F0D651D978B71');
        $this->addSql('ALTER TABLE extra ADD CONSTRAINT FK_4D3F0D651D978B71 FOREIGN KEY (extra_type_id) REFERENCES extra_type (id)');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F52993981C8438BC');
        $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F5299398F55397E8');
        $this->addSql('ALTER TABLE `order` DROP FOREIGN KEY FK_F52993989149D576');
        $this->addSql('DROP TABLE `order`');
        $this->addSql('ALTER TABLE extra DROP FOREIGN KEY FK_4D3F0D651D978B71');
        $this->addSql('ALTER TABLE extra ADD CONSTRAINT FK_4D3F0D651D978B71 FOREIGN KEY (extra_type_id) REFERENCES extra (id) ON UPDATE NO ACTION ON DELETE NO ACTION');
    }
}
