|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Shopsys\FrameworkBundle\Migrations; |
| 6 | + |
| 7 | +use Doctrine\DBAL\Schema\Schema; |
| 8 | +use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; |
| 9 | + |
| 10 | +class Version20240131072541 extends AbstractMigration |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @param \Doctrine\DBAL\Schema\Schema $schema |
| 14 | + */ |
| 15 | + public function up(Schema $schema): void |
| 16 | + { |
| 17 | + $this->dropTrigger('recalc_catnum_tsvector', 'products'); |
| 18 | + $this->dropTrigger('recalc_description_tsvector', 'product_domains'); |
| 19 | + $this->dropTrigger('recalc_name_tsvector', 'product_translations'); |
| 20 | + $this->dropTrigger('recalc_partno_tsvector', 'products'); |
| 21 | + $this->dropTrigger('recalc_product_domain_fulltext_tsvector', 'product_domains'); |
| 22 | + $this->dropTrigger('recalc_product_domain_fulltext_tsvector', 'product_translations'); |
| 23 | + $this->dropTrigger('recalc_product_domain_fulltext_tsvector', 'products'); |
| 24 | + |
| 25 | + $this->dropFunction('set_product_catnum_tsvector'); |
| 26 | + $this->dropFunction('set_product_domain_description_tsvector'); |
| 27 | + $this->dropFunction('set_product_domain_fulltext_tsvector'); |
| 28 | + $this->dropFunction('set_product_partno_tsvector'); |
| 29 | + $this->dropFunction('set_product_translation_name_tsvector'); |
| 30 | + $this->dropFunction('update_product_domain_fulltext_tsvector_by_product'); |
| 31 | + $this->dropFunction('update_product_domain_fulltext_tsvector_by_product_translation'); |
| 32 | + |
| 33 | + $this->dropColumn('catnum_tsvector', 'products'); |
| 34 | + $this->dropColumn('partno_tsvector', 'products'); |
| 35 | + $this->dropColumn('description_tsvector', 'product_domains'); |
| 36 | + $this->dropColumn('fulltext_tsvector', 'product_domains'); |
| 37 | + $this->dropColumn('name_tsvector', 'product_translations'); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @param string $triggerName |
| 42 | + * @param string $tableName |
| 43 | + */ |
| 44 | + private function dropTrigger(string $triggerName, string $tableName): void |
| 45 | + { |
| 46 | + $this->sql(sprintf('DROP TRIGGER IF EXISTS %s ON %s;', $triggerName, $tableName)); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * @param string $functionName |
| 51 | + */ |
| 52 | + private function dropFunction(string $functionName): void |
| 53 | + { |
| 54 | + $this->sql(sprintf('DROP FUNCTION IF EXISTS %s;', $functionName)); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @param string $columnName |
| 59 | + * @param string $tableName |
| 60 | + */ |
| 61 | + private function dropColumn(string $columnName, string $tableName): void |
| 62 | + { |
| 63 | + $this->sql(sprintf('ALTER TABLE %s DROP COLUMN IF EXISTS %s;', $tableName, $columnName)); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @param \Doctrine\DBAL\Schema\Schema $schema |
| 68 | + */ |
| 69 | + public function down(Schema $schema): void |
| 70 | + { |
| 71 | + } |
| 72 | +} |
0 commit comments