Fix indexes

This commit is contained in:
Ajay Ramachandran 2021-03-26 19:02:32 -04:00
parent c7eb5fed35
commit 46524e4298
3 changed files with 11 additions and 6 deletions

View file

@ -5,7 +5,7 @@ CREATE INDEX IF NOT EXISTS "sponsorTimes_hashedIP"
("hashedIP" COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
CREATE INDEX "privateDB_sponsorTimes_videoID"
CREATE INDEX IF NOT EXISTS "privateDB_sponsorTimes_videoID"
ON public."sponsorTimes" USING btree
("videoID" ASC NULLS LAST)
;

View file

@ -1,6 +1,6 @@
-- sponsorTimes
CREATE INDEX IF NOT EXISTS "sponsorTiems_timeSubmitted"
CREATE INDEX IF NOT EXISTS "sponsorTime_timeSubmitted"
ON public."sponsorTimes" USING btree
("timeSubmitted" ASC NULLS LAST)
TABLESPACE pg_default;
@ -14,8 +14,8 @@ CREATE INDEX IF NOT EXISTS "sponsorTimes_UUID"
ON public."sponsorTimes" USING btree
("UUID" COLLATE pg_catalog."default" ASC NULLS LAST)
TABLESPACE pg_default;
CREATE INDEX "sponsorTimes_hashedVideoID_gin"
CREATE INDEX IF NOT EXISTS "sponsorTimes_hashedVideoID_gin"
ON public."sponsorTimes" USING gin
("hashedVideoID" COLLATE pg_catalog."default" gin_trgm_ops, category COLLATE pg_catalog."default" gin_trgm_ops)
TABLESPACE pg_default;
@ -41,7 +41,7 @@ CREATE INDEX IF NOT EXISTS "vipUsers_index"
-- warnings
CREATE INDEX IF NOT EXISTS warnings_index
CREATE INDEX IF NOT EXISTS "warnings_index"
ON public.warnings USING btree
("userID" COLLATE pg_catalog."default" ASC NULLS LAST, "issueTime" DESC NULLS LAST, enabled DESC NULLS LAST)
TABLESPACE pg_default;

View file

@ -24,7 +24,12 @@ export class Postgres implements IDatabase {
// Upgrade database if required
await this.upgradeDB(this.config.fileNamePrefix, this.config.dbSchemaFolder);
await this.applyIndexes(this.config.fileNamePrefix, this.config.dbSchemaFolder);
try {
await this.applyIndexes(this.config.fileNamePrefix, this.config.dbSchemaFolder);
} catch (e) {
Logger.warn("Applying indexes failed. See https://github.com/ajayyy/SponsorBlockServer/wiki/Postgres-Extensions for more information.");
Logger.warn(e);
}
}
}