mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-02 13:14:29 -04:00
Add index migration
This commit is contained in:
parent
ce81caaf14
commit
1e2fd919ff
@ -1,14 +0,0 @@
|
|||||||
CREATE OR REPLACE FUNCTION array_to_string_im(text[], text)
|
|
||||||
RETURNS text LANGUAGE sql IMMUTABLE AS $$SELECT array_to_string($1, $2)$$;
|
|
||||||
|
|
||||||
ALTER TABLE "kyoo"."show_translations" ADD COLUMN "search" "tsvector" GENERATED ALWAYS AS (
|
|
||||||
setweight(to_tsvector('simple', "kyoo"."show_translations"."name"), 'A') ||
|
|
||||||
setweight(to_tsvector('simple', array_to_string_im("kyoo"."show_translations"."aliases", ' ')), 'B') ||
|
|
||||||
setweight(to_tsvector('simple', array_to_string_im("kyoo"."show_translations"."tags", ' ')), 'C') ||
|
|
||||||
setweight(to_tsvector('simple', coalesce("kyoo"."show_translations"."tagline", '')), 'D') ||
|
|
||||||
setweight(to_tsvector('simple', coalesce("kyoo"."show_translations"."description", '')), 'D')
|
|
||||||
) STORED;--> statement-breakpoint
|
|
||||||
CREATE INDEX "search" ON "kyoo"."show_translations" USING gin ("search");--> statement-breakpoint
|
|
||||||
CREATE INDEX "kind" ON "kyoo"."shows" USING hash ("kind");--> statement-breakpoint
|
|
||||||
CREATE INDEX "rating" ON "kyoo"."shows" USING btree ("rating");--> statement-breakpoint
|
|
||||||
CREATE INDEX "startAir" ON "kyoo"."shows" USING btree ("start_air");
|
|
5
api/drizzle/0005_trigram.sql
Normal file
5
api/drizzle/0005_trigram.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
CREATE INDEX "name_trgm" ON "kyoo"."show_translations" USING gin ("name" gin_trgm_ops);--> statement-breakpoint
|
||||||
|
CREATE INDEX "tags" ON "kyoo"."show_translations" USING btree ("tags");--> statement-breakpoint
|
||||||
|
CREATE INDEX "kind" ON "kyoo"."shows" USING hash ("kind");--> statement-breakpoint
|
||||||
|
CREATE INDEX "rating" ON "kyoo"."shows" USING btree ("rating");--> statement-breakpoint
|
||||||
|
CREATE INDEX "startAir" ON "kyoo"."shows" USING btree ("start_air");
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "8e9e90b8-5dbf-4e36-9615-5683c1c1c3e5",
|
"id": "1d98727c-290d-4491-8bb8-74390da0c021",
|
||||||
"prevId": "0d5d6d22-dc13-4f3d-9975-cb7b38f628d4",
|
"prevId": "0d5d6d22-dc13-4f3d-9975-cb7b38f628d4",
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
@ -473,24 +473,29 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"primaryKey": false,
|
"primaryKey": false,
|
||||||
"notNull": false
|
"notNull": false
|
||||||
},
|
|
||||||
"search": {
|
|
||||||
"name": "search",
|
|
||||||
"type": "tsvector",
|
|
||||||
"primaryKey": false,
|
|
||||||
"notNull": false,
|
|
||||||
"generated": {
|
|
||||||
"as": "\n\t\t\tsetweight(to_tsvector('simple', \"kyoo\".\"show_translations\".\"name\"), 'A') ||\n\t\t\tsetweight(to_tsvector('simple', array_to_string(\"kyoo\".\"show_translations\".\"aliases\", ' ')), 'B') ||\n\t\t\tsetweight(to_tsvector('simple', array_to_string(\"kyoo\".\"show_translations\".\"tags\", ' ')), 'C') ||\n\t\t\tsetweight(to_tsvector('simple', coalesce(\"kyoo\".\"show_translations\".\"tagline\", '')), 'D') ||\n\t\t\tsetweight(to_tsvector('simple', coalesce(\"kyoo\".\"show_translations\".\"description\", '')), 'D')\n\t\t",
|
|
||||||
"type": "stored"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indexes": {
|
"indexes": {
|
||||||
"search": {
|
"name_trgm": {
|
||||||
"name": "search",
|
"name": "name_trgm",
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"expression": "search",
|
"expression": "\"name\" gin_trgm_ops",
|
||||||
|
"asc": true,
|
||||||
|
"isExpression": true,
|
||||||
|
"nulls": "last"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isUnique": false,
|
||||||
|
"concurrently": false,
|
||||||
|
"method": "gin",
|
||||||
|
"with": {}
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"name": "tags",
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"expression": "tags",
|
||||||
"isExpression": false,
|
"isExpression": false,
|
||||||
"asc": true,
|
"asc": true,
|
||||||
"nulls": "last"
|
"nulls": "last"
|
||||||
@ -498,7 +503,7 @@
|
|||||||
],
|
],
|
||||||
"isUnique": false,
|
"isUnique": false,
|
||||||
"concurrently": false,
|
"concurrently": false,
|
||||||
"method": "gin",
|
"method": "btree",
|
||||||
"with": {}
|
"with": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
{
|
{
|
||||||
"idx": 5,
|
"idx": 5,
|
||||||
"version": "7",
|
"version": "7",
|
||||||
"when": 1737301476949,
|
"when": 1737742695309,
|
||||||
"tag": "0005_search",
|
"tag": "0005_trigram",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user