<?php declare (strict_types = 1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20180330140308 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, `type` VARCHAR(255) NOT NULL, `meta` VARCHAR(10000) DEFAULT NULL, `name` VARCHAR(255) DEFAULT NULL, `extension` VARCHAR(5) DEFAULT NULL, `link` VARCHAR(255) DEFAULT NULL, `note` VARCHAR(500) DEFAULT NULL, `ticket` VARCHAR(100) NOT NULL, `mimetype` VARCHAR(100) NOT NULL, size INT NOT NULL, `creation_user` VARCHAR(50) NOT NULL, `creation_date` DATETIME NOT NULL, `modified_user` VARCHAR(50) DEFAULT NULL, `modified_date` DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE product_document (id INT AUTO_INCREMENT NOT NULL, product_category_id INT NOT NULL, product_id INT NOT NULL, `document_id` INT DEFAULT NULL, INDEX IDX_13D9E0E15D9C4E11 (`document_id`), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE product_document ADD CONSTRAINT FK_13D9E0E15D9C4E11 FOREIGN KEY (`document_id`) REFERENCES document (`id`) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE product_document DROP FOREIGN KEY FK_13D9E0E15D9C4E11');
$this->addSql('DROP TABLE document');
$this->addSql('DROP TABLE product_document');
}
}