<?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 Version20220830090917 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 credit (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, invoice_id INT NOT NULL, quantity INT NOT NULL, type VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, INDEX IDX_1CC16EFE19EB6921 (client_id), UNIQUE INDEX UNIQ_1CC16EFE2989F1FD (invoice_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE credit_task (id INT AUTO_INCREMENT NOT NULL, credit_id INT NOT NULL, description LONGTEXT NOT NULL, quantity NUMERIC(20, 2) NOT NULL, INDEX IDX_55BC6418CE062FF9 (credit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE credit ADD CONSTRAINT FK_1CC16EFE19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE credit ADD CONSTRAINT FK_1CC16EFE2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id)');
$this->addSql('ALTER TABLE credit_task ADD CONSTRAINT FK_55BC6418CE062FF9 FOREIGN KEY (credit_id) REFERENCES credit (id)');
$this->addSql('ALTER TABLE invoice_amount DROP INDEX IDX_3597ED112989F1FD, ADD UNIQUE INDEX UNIQ_3597ED112989F1FD (invoice_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE credit_task DROP FOREIGN KEY FK_55BC6418CE062FF9');
$this->addSql('DROP TABLE credit');
$this->addSql('DROP TABLE credit_task');
$this->addSql('ALTER TABLE invoice_amount DROP INDEX UNIQ_3597ED112989F1FD, ADD INDEX IDX_3597ED112989F1FD (invoice_id)');
}
}