Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update ts_vector on existing products (#6845)

Damian Wysocki6f9fd12aee74
diff --git a/saleor/product/migrations/0142_update_existing_product_name_ts_vector.py b/saleor/product/migrations/0142_update_existing_product_name_ts_vector.py
new file mode 100644
index 0000000000..8359dddd2a
--- /dev/null
+++ b/saleor/product/migrations/0142_update_existing_product_name_ts_vector.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.1.5 on 2021-02-05 09:09
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("product", "0141_update_product_ts_vector"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ """
+ UPDATE product_product
+ SET search_vector =
+ setweight(to_tsvector('pg_catalog.english', coalesce(name, '')), 'A') ||
+ setweight(
+ to_tsvector('pg_catalog.english', coalesce(description_plaintext, '')), 'B'
+ );
+ """
+ ),
+ ]