Skip to content

Commit d2003ca

Browse files
removed unused tsvector columns
- database fulltext search was already replaced by elasticsearch
1 parent 7718508 commit d2003ca

4 files changed

Lines changed: 72 additions & 30 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
}

src/Model/Product/Product.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,12 @@ class Product extends AbstractTranslatableEntity
6363
*/
6464
protected $catnum;
6565

66-
/**
67-
* @var string
68-
* @ORM\Column(type="tsvector", nullable=false)
69-
*/
70-
protected $catnumTsvector;
71-
7266
/**
7367
* @var string|null
7468
* @ORM\Column(type="string", length=100, nullable=true)
7569
*/
7670
protected $partno;
7771

78-
/**
79-
* @var string
80-
* @ORM\Column(type="tsvector", nullable=false)
81-
*/
82-
protected $partnoTsvector;
83-
8472
/**
8573
* @var string|null
8674
* @ORM\Column(type="string", length=100, nullable=true)

src/Model/Product/ProductDomain.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@ class ProductDomain
6464
*/
6565
protected $shortDescription;
6666

67-
/**
68-
* @var string
69-
* @ORM\Column(type="tsvector", nullable=false)
70-
*/
71-
protected $descriptionTsvector;
72-
73-
/**
74-
* @var string
75-
* @ORM\Column(type="tsvector", nullable=false)
76-
*/
77-
protected $fulltextTsvector;
78-
7967
/**
8068
* @var string|null
8169
* @ORM\Column(type="text", nullable=true)

src/Model/Product/ProductTranslation.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ class ProductTranslation extends AbstractTranslation
2828
*/
2929
protected $name;
3030

31-
/**
32-
* @var string
33-
* @ORM\Column(type="tsvector", nullable=false)
34-
*/
35-
protected $nameTsvector;
36-
3731
/**
3832
* @var string|null
3933
* @ORM\Column(type="string", length=255, nullable=true)

0 commit comments

Comments
 (0)