<?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 Version20220905172932 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 agency (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, nom VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE customer (id INT AUTO_INCREMENT NOT NULL, agency INT NOT NULL, code VARCHAR(255) NOT NULL, nom VARCHAR(255) DEFAULT NULL, email VARCHAR(255) NOT NULL, contact VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_81398E0970C0C6E6 (agency), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE invoice (id INT AUTO_INCREMENT NOT NULL, customer INT NOT NULL, code VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, parent_code VARCHAR(255) NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_9065174481398E09 (customer), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE item_invoice (id INT AUTO_INCREMENT NOT NULL, invoice INT NOT NULL, libelle VARCHAR(255) NOT NULL, qte INT NOT NULL, amount INT NOT NULL, montant INT NOT NULL, frais INT NOT NULL, remise DOUBLE PRECISION NOT NULL, tva INT NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_9B38311090651744 (invoice), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE method_payment (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, disabled TINYINT(1) NOT NULL, display TINYINT(1) NOT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE transaction_invoice (id INT AUTO_INCREMENT NOT NULL, invoice INT NOT NULL, method_payment_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL, amount INT NOT NULL, msisdn VARCHAR(255) NOT NULL, pay TINYINT(1) NOT NULL, status INT NOT NULL, response LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_E6CF2BA690651744 (invoice), INDEX IDX_E6CF2BA6D6D0C1D3 (method_payment_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE customer ADD CONSTRAINT FK_81398E0970C0C6E6 FOREIGN KEY (agency) REFERENCES agency (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_9065174481398E09 FOREIGN KEY (customer) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE item_invoice ADD CONSTRAINT FK_9B38311090651744 FOREIGN KEY (invoice) REFERENCES invoice (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction_invoice ADD CONSTRAINT FK_E6CF2BA690651744 FOREIGN KEY (invoice) REFERENCES invoice (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction_invoice ADD CONSTRAINT FK_E6CF2BA6D6D0C1D3 FOREIGN KEY (method_payment_id) REFERENCES method_payment (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE customer DROP FOREIGN KEY FK_81398E0970C0C6E6');
$this->addSql('ALTER TABLE invoice DROP FOREIGN KEY FK_9065174481398E09');
$this->addSql('ALTER TABLE item_invoice DROP FOREIGN KEY FK_9B38311090651744');
$this->addSql('ALTER TABLE transaction_invoice DROP FOREIGN KEY FK_E6CF2BA690651744');
$this->addSql('ALTER TABLE transaction_invoice DROP FOREIGN KEY FK_E6CF2BA6D6D0C1D3');
$this->addSql('DROP TABLE agency');
$this->addSql('DROP TABLE customer');
$this->addSql('DROP TABLE invoice');
$this->addSql('DROP TABLE item_invoice');
$this->addSql('DROP TABLE method_payment');
$this->addSql('DROP TABLE transaction_invoice');
}
}