Fix create extension place (move out of migration)

This commit is contained in:
Zoe Roux 2025-02-21 22:53:52 +01:00
parent 7fb23bb490
commit b18ab07e3e
3 changed files with 6 additions and 7 deletions

View File

@ -4,7 +4,7 @@
# either an hard-coded secret to decode jwts or empty to use keibi's public secret.
# this should only be used in tests
JWT_SECRET=
# keibi's server to retrive the public jwt secret
# keibi's server to retrieve the public jwt secret
AUHT_SERVER=http://auth:4568
POSTGRES_USER=kyoo

View File

@ -1,5 +1,3 @@
create extension if not exists pg_trgm;
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

View File

@ -6,7 +6,7 @@ import * as schema from "./schema";
const dbConfig = {
user: process.env.POSTGRES_USER ?? "kyoo",
password: process.env.POSTGRES_PASSWORD ?? "password",
database: process.env.POSTGRES_DB ?? "kyooDB",
database: process.env.POSTGRES_DB ?? "kyoo",
host: process.env.POSTGRES_SERVER ?? "postgres",
port: Number(process.env.POSTGRES_PORT) || 5432,
ssl: false,
@ -19,9 +19,10 @@ export const db = drizzle({
export const migrate = async () => {
await db.execute(
sql.raw(
`ALTER DATABASE "${dbConfig.database}" SET pg_trgm.word_similarity_threshold = 0.4;`,
),
sql.raw(`
create extension if not exists pg_trgm;
ALTER DATABASE "${dbConfig.database}" SET pg_trgm.word_similarity_threshold = 0.4;
`),
);
await migrateDb(db, {
migrationsSchema: "kyoo",