migrations/Version20230720153118.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230720153118 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE accessory (id INT AUTO_INCREMENT NOT NULL, product_category_id INT NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_A1B1251CBE6903FD (product_category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE product_trade_in_accessory (product_trade_in_id INT NOT NULL, accessory_id INT NOT NULL, INDEX IDX_26946F8D96DB30CF (product_trade_in_id), INDEX IDX_26946F8D27E8CC78 (accessory_id), PRIMARY KEY(product_trade_in_id, accessory_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('ALTER TABLE accessory ADD CONSTRAINT FK_A1B1251CBE6903FD FOREIGN KEY (product_category_id) REFERENCES product_categorie (id)');
  21.         $this->addSql('ALTER TABLE product_trade_in_accessory ADD CONSTRAINT FK_26946F8D96DB30CF FOREIGN KEY (product_trade_in_id) REFERENCES product_trade_in (id) ON DELETE CASCADE');
  22.         $this->addSql('ALTER TABLE product_trade_in_accessory ADD CONSTRAINT FK_26946F8D27E8CC78 FOREIGN KEY (accessory_id) REFERENCES accessory (id) ON DELETE CASCADE');
  23.         $this->addSql('ALTER TABLE product_trade_in ADD more_accessory LONGTEXT DEFAULT NULL, ADD serial_number VARCHAR(30) DEFAULT NULL, ADD warranty_duration INT DEFAULT NULL, ADD ps_selling_id INT DEFAULT NULL, ADD selled TINYINT(1) DEFAULT 0, ADD selled_price DOUBLE PRECISION DEFAULT NULL');
  24.     }
  25.     public function down(Schema $schema): void
  26.     {
  27.         // this down() migration is auto-generated, please modify it to your needs
  28.         $this->addSql('ALTER TABLE accessory DROP FOREIGN KEY FK_A1B1251CBE6903FD');
  29.         $this->addSql('ALTER TABLE product_trade_in_accessory DROP FOREIGN KEY FK_26946F8D96DB30CF');
  30.         $this->addSql('ALTER TABLE product_trade_in_accessory DROP FOREIGN KEY FK_26946F8D27E8CC78');
  31.         $this->addSql('DROP TABLE accessory');
  32.         $this->addSql('DROP TABLE product_trade_in_accessory');
  33.         $this->addSql('ALTER TABLE product_trade_in DROP more_accessory, DROP serial_number, DROP warranty_duration, DROP ps_selling_id, DROP selled, DROP selled_price');
  34.     }
  35. }