migrations/Version20240910194833.php line 1

Open in your IDE?
  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 Version20240910194833 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 brand (id INT AUTO_INCREMENT NOT NULL, seo_id INT DEFAULT NULL, post_id INT DEFAULT NULL, jp_id VARCHAR(45) DEFAULT NULL, title VARCHAR(45) NOT NULL, publish TINYINT(1) NOT NULL, featured TINYINT(1) NOT NULL, tarteb SMALLINT DEFAULT 0, deleted DATETIME DEFAULT NULL, deleted_by VARCHAR(255) DEFAULT NULL, created DATETIME NOT NULL, creator VARCHAR(255) NOT NULL, modified DATETIME NOT NULL, modified_by VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1C52F95897E3DD86 (seo_id), UNIQUE INDEX UNIQ_1C52F9584B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19. $this->addSql('CREATE TABLE brand_translations (translatable_id INT NOT NULL, language_id INT NOT NULL, title VARCHAR(100) NOT NULL, INDEX IDX_B018D342C2AC5D3 (translatable_id), INDEX IDX_B018D3482F1BAF4 (language_id), PRIMARY KEY(translatable_id, language_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20. $this->addSql('ALTER TABLE brand ADD CONSTRAINT FK_1C52F95897E3DD86 FOREIGN KEY (seo_id) REFERENCES seo (id)');
  21. $this->addSql('ALTER TABLE brand ADD CONSTRAINT FK_1C52F9584B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
  22. $this->addSql('ALTER TABLE brand_translations ADD CONSTRAINT FK_B018D342C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES brand (id)');
  23. $this->addSql('ALTER TABLE brand_translations ADD CONSTRAINT FK_B018D3482F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
  24. $this->addSql('ALTER TABLE blog CHANGE subtitle subtitle VARCHAR(255) DEFAULT NULL');
  25. $this->addSql('ALTER TABLE product ADD brand_id INT DEFAULT NULL');
  26. $this->addSql('ALTER TABLE product ADD CONSTRAINT FK_D34A04AD44F5D008 FOREIGN KEY (brand_id) REFERENCES brand (id)');
  27. $this->addSql('CREATE INDEX IDX_D34A04AD44F5D008 ON product (brand_id)');
  28. $this->addSql('ALTER TABLE product_search ADD brand_id INT DEFAULT NULL');
  29. $this->addSql('ALTER TABLE product_search ADD CONSTRAINT FK_D68C9A0344F5D008 FOREIGN KEY (brand_id) REFERENCES brand (id)');
  30. $this->addSql('CREATE INDEX IDX_D68C9A0344F5D008 ON product_search (brand_id)');
  31. $this->addSql('ALTER TABLE product_price ADD weight DOUBLE PRECISION DEFAULT NULL');
  32. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (10, 'Brand', 'brand_index', 'brand/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  33. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1000, 1000, NULL, NULL, 0, 1, 1, 10);");
  34. $this->addSql("INSERT INTO image_setting_has_type (radio_button, width, height, thumb_width, thumb_height, validate_width_and_height, validate_size, image_type_id, image_setting_id) VALUES (1, 1920, 300, NULL, NULL, 0, 1, 3, 10);");
  35. $this->addSql('INSERT INTO seo_base_route (entity_name, base_route, created, creator, modified, modified_by) VALUES ("App\\\ProductBundle\\\Entity\\\Brand", "brand", NOW(), "System", NOW(), "System");');
  36. $this->addSql('INSERT INTO seo_base_route (entity_name, base_route, created, creator, modified, modified_by) VALUES ("App\\\ProductBundle\\\Entity\\\Product", "product", NOW(), "System", NOW(), "System");');
  37. }
  38. public function down(Schema $schema): void
  39. {
  40. // this down() migration is auto-generated, please modify it to your needs
  41. $this->addSql('ALTER TABLE product DROP FOREIGN KEY FK_D34A04AD44F5D008');
  42. $this->addSql('ALTER TABLE product_search DROP FOREIGN KEY FK_D68C9A0344F5D008');
  43. $this->addSql('ALTER TABLE brand DROP FOREIGN KEY FK_1C52F95897E3DD86');
  44. $this->addSql('ALTER TABLE brand DROP FOREIGN KEY FK_1C52F9584B89032C');
  45. $this->addSql('ALTER TABLE brand_translations DROP FOREIGN KEY FK_B018D342C2AC5D3');
  46. $this->addSql('ALTER TABLE brand_translations DROP FOREIGN KEY FK_B018D3482F1BAF4');
  47. $this->addSql('DROP TABLE brand');
  48. $this->addSql('DROP TABLE brand_translations');
  49. $this->addSql('ALTER TABLE blog CHANGE subtitle subtitle VARCHAR(255) NOT NULL');
  50. $this->addSql('DROP INDEX IDX_D34A04AD44F5D008 ON product');
  51. $this->addSql('ALTER TABLE product DROP brand_id');
  52. $this->addSql('DROP INDEX IDX_D68C9A0344F5D008 ON product_search');
  53. $this->addSql('ALTER TABLE product_search DROP brand_id');
  54. $this->addSql('ALTER TABLE product_price DROP weight');
  55. $this->addSql('DELETE FROM image_setting WHERE id = 10');
  56. $this->addSql('DELETE FROM image_setting_has_type WHERE image_setting_id = 10');
  57. $this->addSql('DELETE FROM seo_base_route WHERE entity_name = "App\\ProductBundle\\Entity\\Brand"');
  58. }
  59. }