migrations/Version20230316153825.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use App\OnlinePaymentBundle\Enum\PaymentMethodEnum;
  5. use App\SeoBundle\Entity\Seo;
  6. use Doctrine\DBAL\Schema\Schema;
  7. use Doctrine\Migrations\AbstractMigration;
  8. use PN\SeoBundle\Entity\SeoBaseRoute;
  9. use PN\SeoBundle\Entity\SeoPage;
  10. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  11. use Symfony\Component\DependencyInjection\ContainerAwareTrait;
  12. /**
  13. * Auto-generated Migration: Please modify to your needs!
  14. */
  15. final class Version20230316153825 extends AbstractMigration implements ContainerAwareInterface
  16. {
  17. use ContainerAwareTrait;
  18. public function getDescription(): string
  19. {
  20. return 'Initial Values for C-Reality';
  21. }
  22. public function up(Schema $schema): void
  23. {
  24. $this->addSql("INSERT INTO `payment_method` (`title`, `note`, `type`, `active`, `fees`, `deleted`, `deleted_by`, `created`, `creator`, `modified`, `modified_by`) VALUES ('ValU', NULL, :type, '1', '0', NULL, NULL, NOW(), 'System', NOW(), 'System')",
  25. ["type" => PaymentMethodEnum::ValU->value]
  26. );
  27. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (8, 'OriginalDesign', 'original_design_edit', 'original-design/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  28. $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, 8);");
  29. $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 (0, 1000, 1000, NULL, NULL, 0, 1, 2, 8);");
  30. $this->addSql("INSERT INTO image_setting (id, entity_name, back_route, upload_path, auto_resize, quality, gallery, created, creator, modified, modified_by) VALUES (9, 'Material', 'material_category_index', 'material/', 1, 1, 0, NOW(), 'System', NOW(), 'System');");
  31. $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, 9);");
  32. // DYNAMIC CONTENT
  33. $this->addSql("INSERT INTO `dynamic_content` (`id`, `title`) VALUES (2, 'Home Page')");
  34. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (11, 2, 'Info Section Title', 'GOOD DESIGN IS ALL ABOUT STORYTELLING!', 1, NULL, NULL, NULL);");
  35. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (12, 2, 'Info Section #1 Image', NULL, 4, '500px * 300px', 500, 300);");
  36. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (13, 2, 'Info Section #1 Title', 'WHO WE ARE', 1, NULL, NULL, NULL);");
  37. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (14, 2, 'Info Section #1 Text', 'Our brand philosophy is a constant reminder that any concept is not complete without coming to reality, we have turned it into our motto and a call for action to implement this concept throughout.', 2, NULL, NULL, NULL);");
  38. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (15, 2, 'Info Section #2 Image', NULL, 4, '500px * 300px', 500, 300);");
  39. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (16, 2, 'Info Section #2 Title', 'OUR MISSION', 1, NULL, NULL, NULL);");
  40. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (17, 2, 'Info Section #2 Text', 'Our brand philosophy is a constant reminder that any concept is not complete without coming to reality, we have turned it into our motto and a call for action to implement this concept throughout.', 2, NULL, NULL, NULL);");
  41. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (18, 2, 'Info Section #3 Image', NULL, 4, '500px * 300px', 500, 300);");
  42. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (19, 2, 'Info Section #3 Title', 'OUR VISION', 1, NULL, NULL, NULL);");
  43. $this->addSql("INSERT INTO `dynamic_content_attribute` (`id`, `dynamic_content_id`, `title`, `value`, `type`, `hint`, `image_width`, `image_height`) VALUES (20, 2, 'Info Section #3 Text', 'Our brand philosophy is a constant reminder that any concept is not complete without coming to reality, we have turned it into our motto and a call for action to implement this concept throughout.', 2, NULL, NULL, NULL);");
  44. $this->addSql('CREATE TABLE original_design (id INT AUTO_INCREMENT NOT NULL, seo_id INT DEFAULT NULL, post_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, tarteb SMALLINT DEFAULT NULL, publish TINYINT(1) NOT NULL, featured TINYINT(1) NOT NULL, 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_9E3379E097E3DD86 (seo_id), UNIQUE INDEX UNIQ_9E3379E04B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  45. $this->addSql('CREATE TABLE original_design_translations (translatable_id INT NOT NULL, language_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, INDEX IDX_E57C69452C2AC5D3 (translatable_id), INDEX IDX_E57C694582F1BAF4 (language_id), PRIMARY KEY(translatable_id, language_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  46. $this->addSql('ALTER TABLE original_design ADD CONSTRAINT FK_9E3379E097E3DD86 FOREIGN KEY (seo_id) REFERENCES seo (id)');
  47. $this->addSql('ALTER TABLE original_design ADD CONSTRAINT FK_9E3379E04B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
  48. $this->addSql('ALTER TABLE original_design_translations ADD CONSTRAINT FK_E57C69452C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES original_design (id)');
  49. $this->addSql('ALTER TABLE original_design_translations ADD CONSTRAINT FK_E57C694582F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
  50. $this->addSql('CREATE TABLE material (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, post_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, tarteb SMALLINT DEFAULT NULL, publish TINYINT(1) NOT NULL, 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, INDEX IDX_7CBE759512469DE2 (category_id), UNIQUE INDEX UNIQ_7CBE75954B89032C (post_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  51. $this->addSql('CREATE TABLE material_category (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, tarteb SMALLINT DEFAULT NULL, publish TINYINT(1) NOT NULL, 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, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  52. $this->addSql('CREATE TABLE material_category_translations (translatable_id INT NOT NULL, language_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, INDEX IDX_5227BC222C2AC5D3 (translatable_id), INDEX IDX_5227BC2282F1BAF4 (language_id), PRIMARY KEY(translatable_id, language_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  53. $this->addSql('CREATE TABLE material_translations (translatable_id INT NOT NULL, language_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, INDEX IDX_C8CF4E872C2AC5D3 (translatable_id), INDEX IDX_C8CF4E8782F1BAF4 (language_id), PRIMARY KEY(translatable_id, language_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  54. $this->addSql('ALTER TABLE material ADD CONSTRAINT FK_7CBE759512469DE2 FOREIGN KEY (category_id) REFERENCES material_category (id)');
  55. $this->addSql('ALTER TABLE material ADD CONSTRAINT FK_7CBE75954B89032C FOREIGN KEY (post_id) REFERENCES post (id)');
  56. $this->addSql('ALTER TABLE material_category_translations ADD CONSTRAINT FK_5227BC222C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES material_category (id)');
  57. $this->addSql('ALTER TABLE material_category_translations ADD CONSTRAINT FK_5227BC2282F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
  58. $this->addSql('ALTER TABLE material_translations ADD CONSTRAINT FK_C8CF4E872C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES material (id)');
  59. $this->addSql('ALTER TABLE material_translations ADD CONSTRAINT FK_C8CF4E8782F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id)');
  60. }
  61. public function postUp(Schema $schema): void
  62. {
  63. $this->newSeo('Original Designs Page', 'Original Designs', 'original-designs', 'original-designs');
  64. $this->newSeo('Materials Page', 'Materials', 'materials', 'materials');
  65. }
  66. private function newSeo($seoPageTitle, $seoTitle, $seoPageType, $seoSlug): void
  67. {
  68. //getting entity manager
  69. $em = $this->container->get('doctrine.orm.entity_manager');
  70. $seoPage = new SeoPage();
  71. $seoPage->setTitle($seoPageTitle);
  72. $seoPage->setType($seoPageType);
  73. $seoPage->setCreated(new \DateTime());
  74. $seoPage->setCreator('System');
  75. $seoPage->setModified(new \DateTime());
  76. $seoPage->setModifiedBy('System');
  77. $seo = new Seo();
  78. $seo->setSeoBaseRoute($em->getRepository(SeoBaseRoute::class)->findByEntity($seoPage));
  79. $seo->setTitle($seoTitle);
  80. $seo->setSlug($seoSlug);
  81. $seo->setState(1);
  82. $seo->setLastModified(new \DateTime());
  83. $seoPage->setSeo($seo);
  84. $em->persist($seoPage);
  85. $em->persist($seo);
  86. $em->flush();
  87. }
  88. public function down(Schema $schema): void
  89. {
  90. $this->addSql('ALTER TABLE original_design DROP FOREIGN KEY FK_9E3379E097E3DD86');
  91. $this->addSql('ALTER TABLE original_design DROP FOREIGN KEY FK_9E3379E04B89032C');
  92. $this->addSql('ALTER TABLE original_design_translations DROP FOREIGN KEY FK_E57C69452C2AC5D3');
  93. $this->addSql('ALTER TABLE original_design_translations DROP FOREIGN KEY FK_E57C694582F1BAF4');
  94. $this->addSql('ALTER TABLE material DROP FOREIGN KEY FK_7CBE759512469DE2');
  95. $this->addSql('ALTER TABLE material DROP FOREIGN KEY FK_7CBE75954B89032C');
  96. $this->addSql('ALTER TABLE material_category_translations DROP FOREIGN KEY FK_5227BC222C2AC5D3');
  97. $this->addSql('ALTER TABLE material_category_translations DROP FOREIGN KEY FK_5227BC2282F1BAF4');
  98. $this->addSql('ALTER TABLE material_translations DROP FOREIGN KEY FK_C8CF4E872C2AC5D3');
  99. $this->addSql('ALTER TABLE material_translations DROP FOREIGN KEY FK_C8CF4E8782F1BAF4');
  100. $this->addSql('DROP TABLE material');
  101. $this->addSql('DROP TABLE material_category');
  102. $this->addSql('DROP TABLE material_category_translations');
  103. $this->addSql('DROP TABLE material_translations');
  104. }
  105. }